Mercurial > emacs
comparison lisp/progmodes/python.el @ 101984:84b9607bddb0
(python-use-skeletons): Re-add.
(def-python-skeleton): Use it.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 12 Feb 2009 18:16:26 +0000 |
parents | fcd47e055a66 |
children | 603bb57bb542 |
comparison
equal
deleted
inserted
replaced
101983:70db2d7b280c | 101984:84b9607bddb0 |
---|---|
2203 (when (integerp line) | 2203 (when (integerp line) |
2204 (goto-line line)))) | 2204 (goto-line line)))) |
2205 | 2205 |
2206 ;;;; Skeletons | 2206 ;;;; Skeletons |
2207 | 2207 |
2208 (defcustom python-use-skeletons nil | |
2209 "Non-nil means template skeletons will be automagically inserted. | |
2210 This happens when pressing \"if<SPACE>\", for example, to prompt for | |
2211 the if condition." | |
2212 :type 'boolean | |
2213 :group 'python) | |
2214 | |
2208 (define-abbrev-table 'python-mode-abbrev-table () | 2215 (define-abbrev-table 'python-mode-abbrev-table () |
2209 "Abbrev table for Python mode." | 2216 "Abbrev table for Python mode." |
2210 :case-fixed t | 2217 :case-fixed t |
2211 ;; Allow / inside abbrevs. | 2218 ;; Allow / inside abbrevs. |
2212 :regexp "\\(?:^\\|[^/]\\)\\<\\([[:word:]/]+\\)\\W*" | 2219 :regexp "\\(?:^\\|[^/]\\)\\<\\([[:word:]/]+\\)\\W*" |
2219 (let* ((name (symbol-name name)) | 2226 (let* ((name (symbol-name name)) |
2220 (function (intern (concat "python-insert-" name)))) | 2227 (function (intern (concat "python-insert-" name)))) |
2221 `(progn | 2228 `(progn |
2222 ;; Usual technique for inserting a skeleton, but expand | 2229 ;; Usual technique for inserting a skeleton, but expand |
2223 ;; to the original abbrev instead if in a comment or string. | 2230 ;; to the original abbrev instead if in a comment or string. |
2224 (define-abbrev python-mode-abbrev-table ,name "" | 2231 (when python-use-skeletons |
2225 ',function | 2232 (define-abbrev python-mode-abbrev-table ,name "" |
2226 nil t) ; system abbrev | 2233 ',function |
2234 nil t)) ; system abbrev | |
2227 (define-skeleton ,function | 2235 (define-skeleton ,function |
2228 ,(format "Insert Python \"%s\" template." name) | 2236 ,(format "Insert Python \"%s\" template." name) |
2229 ,@elements))))) | 2237 ,@elements))))) |
2230 (put 'def-python-skeleton 'lisp-indent-function 2) | 2238 (put 'def-python-skeleton 'lisp-indent-function 2) |
2231 | 2239 |