* 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

@ -1,3 +1,9 @@
2012-06-18 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/python.el (python-rx-constituents): Move backquote.
(python-skeleton-define, python-define-auxiliary-skeleton):
Use `declare'.
2012-06-18 Michael Albinus <michael.albinus@gmx.de> 2012-06-18 Michael Albinus <michael.albinus@gmx.de>
* minibuffer.el (read-file-name-default): Revert the patch from * minibuffer.el (read-file-name-default): Revert the patch from

View file

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