* lisp/progmodes/python.el (python-rx-constituents): Move backquote.

(python-skeleton-define, python-define-auxiliary-skeleton): Use `declare'.
This commit is contained in:
Stefan Monnier 2012-06-18 16:41:23 -04:00
parent 6b11952a33
commit 25f09295fa
2 changed files with 22 additions and 14 deletions

View file

@ -308,29 +308,31 @@
(eval-when-compile
(defconst python-rx-constituents
(list
`(block-start . ,(rx symbol-start
`((block-start . ,(rx symbol-start
(or "def" "class" "if" "elif" "else" "try"
"except" "finally" "for" "while" "with")
symbol-end))
`(decorator . ,(rx line-start (* space) ?@ (any letter ?_)
(decorator . ,(rx line-start (* space) ?@ (any letter ?_)
(* (any word ?_))))
`(defun . ,(rx symbol-start (or "def" "class") symbol-end))
`(if-name-main . ,(rx line-start "if" (+ space) "__name__"
(defun . ,(rx symbol-start (or "def" "class") symbol-end))
(if-name-main . ,(rx line-start "if" (+ space) "__name__"
(+ space) "==" (+ space)
(any ?' ?\") "__main__" (any ?' ?\")
(* space) ?:))
`(symbol-name . ,(rx (any letter ?_) (* (any word ?_))))
`(open-paren . ,(rx (or "{" "[" "(")))
`(close-paren . ,(rx (or "}" "]" ")")))
`(simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))
`(not-simple-operator . ,(rx
(symbol-name . ,(rx (any letter ?_) (* (any word ?_))))
(open-paren . ,(rx (or "{" "[" "(")))
(close-paren . ,(rx (or "}" "]" ")")))
(simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))
;; FIXME: rx should support (not simple-operator).
(not-simple-operator . ,(rx
(not
(any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))))
`(operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">"
;; FIXME: Use regexp-opt.
(operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">"
"=" "%" "**" "//" "<<" ">>" "<=" "!="
"==" ">=" "is" "not")))
`(assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**="
;; FIXME: Use regexp-opt.
(assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**="
">>=" "<<=" "&=" "^=" "|="))))
"Additional Python specific sexps for `python-rx'"))
@ -2146,6 +2148,7 @@ the if condition."
"Define a `python-mode' skeleton using NAME DOC and SKEL.
The skeleton will be bound to python-skeleton-NAME and will
be added to `python-mode-abbrev-table'."
(declare (indent 2))
(let* ((name (symbol-name name))
(function-name (intern (concat "python-skeleton-" name))))
`(progn
@ -2156,11 +2159,11 @@ be added to `python-mode-abbrev-table'."
,(or doc
(format "Insert %s statement." name))
,@skel))))
(put 'python-skeleton-define 'lisp-indent-function 2)
(defmacro python-define-auxiliary-skeleton (name doc &optional &rest skel)
"Define a `python-mode' auxiliary skeleton using NAME DOC and SKEL.
The skeleton will be bound to python-skeleton-NAME."
(declare (indent 2))
(let* ((name (symbol-name name))
(function-name (intern (concat "python-skeleton--" name)))
(msg (format
@ -2176,7 +2179,6 @@ The skeleton will be bound to python-skeleton-NAME."
(unless (y-or-n-p ,msg)
(signal 'quit t))
,@skel)))
(put 'python-define-auxiliary-skeleton 'lisp-indent-function 2)
(python-define-auxiliary-skeleton else nil)