[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/progmodes/python.el,v
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/progmodes/python.el,v |
Date: |
Thu, 17 Apr 2008 20:09:55 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Stefan Monnier <monnier> 08/04/17 20:09:54
Index: progmodes/python.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/python.el,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- progmodes/python.el 22 Feb 2008 17:49:48 -0000 1.84
+++ progmodes/python.el 17 Apr 2008 20:09:54 -0000 1.85
@@ -296,9 +296,7 @@
("Templates..."
:help "Expand templates for compound statements"
:filter (lambda (&rest junk)
- (mapcar (lambda (elt)
- (vector (car elt) (cdr elt) t))
- python-skeletons))) ; defined later
+ (abbrev-table-menu python-mode-abbrev-table)))
"-"
["Start interpreter" python-shell
:help "Run `inferior' Python in separate buffer"]
@@ -2202,39 +2200,24 @@
;;;; Skeletons
-(defcustom python-use-skeletons nil
- "Non-nil means template skeletons will be automagically inserted.
-This happens when pressing \"if<SPACE>\", for example, to prompt for
-the if condition."
- :type 'boolean
- :group 'python)
-
-(defvar python-skeletons nil
- "Alist of named skeletons for Python mode.
-Elements are of the form (NAME . EXPANDER-FUNCTION).")
-
(define-abbrev-table 'python-mode-abbrev-table ()
- "Abbrev table for Python mode.
-The default contents correspond to the elements of `python-skeletons'."
- ;; Allow / in abbrevs.
- :regexp "\\<\\([[:word:]/]+\\)\\W*")
+ "Abbrev table for Python mode."
+ :case-fixed t
+ ;; Allow / inside abbrevs.
+ :regexp "\\(?:^\\|[^/]\\)\\<\\([[:word:]/]+\\)\\W*"
+ ;; Only expand in code.
+ :enable-function (lambda () (not (python-in-string/comment))))
(eval-when-compile
- ;; Define a user-level skeleton and add it to `python-skeletons' and
- ;; the abbrev table.
+ ;; Define a user-level skeleton and add it to the abbrev table.
(defmacro def-python-skeleton (name &rest elements)
(let* ((name (symbol-name name))
(function (intern (concat "python-insert-" name))))
`(progn
- (add-to-list 'python-skeletons ',(cons name function))
;; Usual technique for inserting a skeleton, but expand
;; to the original abbrev instead if in a comment or string.
(define-abbrev python-mode-abbrev-table ,name ""
- ;; Quote this to give a readable abbrev table.
- '(lambda ()
- (if (python-in-string/comment)
- (insert ,name)
- (,function)))
+ ',function
nil t) ; system abbrev
(define-skeleton ,function
,(format "Insert Python \"%s\" template." name)
@@ -2327,13 +2310,14 @@
(interactive
(list (completing-read (format "Template to expand (default %s): "
python-default-template)
- python-skeletons nil t)))
+ python-mode-abbrev-table nil t nil nil
+ python-default-template)))
(if (equal "" name)
(setq name python-default-template)
(setq python-default-template name))
- (let ((func (cdr (assoc name python-skeletons))))
- (if func
- (funcall func)
+ (let ((sym (abbrev-symbol name python-mode-abbrev-table)))
+ (if sym
+ (abbrev-insert sym)
(error "Undefined template: %s" name))))
;;;; Bicycle Repair Man support
@@ -2397,22 +2381,6 @@
(defvar eldoc-documentation-function)
(defvar python-mode-running) ;Dynamically scoped var.
-;; Stuff to allow expanding abbrevs with non-word constituents.
-(defun python-abbrev-pc-hook ()
- "Reset the syntax table after possibly expanding abbrevs."
- (remove-hook 'post-command-hook 'python-abbrev-pc-hook t)
- (set-syntax-table python-mode-syntax-table))
-
-(defvar python-abbrev-syntax-table
- (copy-syntax-table python-mode-syntax-table)
- "Syntax table used when expanding abbrevs.")
-
-(defun python-pea-hook ()
- "Set the syntax table before possibly expanding abbrevs."
- (set-syntax-table python-abbrev-syntax-table)
- (add-hook 'post-command-hook 'python-abbrev-pc-hook nil t))
-(modify-syntax-entry ?/ "w" python-abbrev-syntax-table)
-
;;;###autoload
(define-derived-mode python-mode fundamental-mode "Python"
"Major mode for editing Python files.
@@ -2503,7 +2471,6 @@
'((< '(backward-delete-char-untabify (min python-indent
(current-column))))
(^ '(- (1+ (current-indentation))))))
- (add-hook 'pre-abbrev-expand-hook 'python-pea-hook nil t)
(if (featurep 'hippie-exp)
(set (make-local-variable 'hippie-expand-try-functions-list)
(cons 'symbol-completion-try-complete
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/progmodes/python.el,v,
Stefan Monnier <=