emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112309: * lisp/progmodes/python.el (


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112309: * lisp/progmodes/python.el (python-mode-skeleton-abbrev-table): Rename from
Date: Tue, 16 Apr 2013 13:28:11 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 112309
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2013-04-16 13:28:11 -0400
message:
  * lisp/progmodes/python.el (python-mode-skeleton-abbrev-table): Rename from
  python-mode-abbrev-table.
  (python-skeleton-define): Adjust accordingly.
  (python-mode-abbrev-table): New table that inherits from it so that
  python-skeleton-autoinsert does not affect non-skeleton abbrevs.
  * lisp/abbrev.el (abbrev--symbol): New function, extracted from abbrev-symbol.
  (abbrev-symbol): Use it.
  (abbrev--before-point): Use it since we already handle inheritance.
modified:
  lisp/ChangeLog
  lisp/abbrev.el
  lisp/progmodes/python.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-04-16 16:38:31 +0000
+++ b/lisp/ChangeLog    2013-04-16 17:28:11 +0000
@@ -1,3 +1,15 @@
+2013-04-16  Stefan Monnier  <address@hidden>
+
+       * progmodes/python.el (python-mode-skeleton-abbrev-table): Rename from
+       python-mode-abbrev-table.
+       (python-skeleton-define): Adjust accordingly.
+       (python-mode-abbrev-table): New table that inherits from it so that
+       python-skeleton-autoinsert does not affect non-skeleton abbrevs.
+
+       * abbrev.el (abbrev--symbol): New function, extracted from 
abbrev-symbol.
+       (abbrev-symbol): Use it.
+       (abbrev--before-point): Use it since we already handle inheritance.
+
 2013-04-16  Leo Liu  <address@hidden>
 
        * progmodes/octave-mod.el (octave-mode-map): Remove redundant key

=== modified file 'lisp/abbrev.el'
--- a/lisp/abbrev.el    2013-01-01 09:11:05 +0000
+++ b/lisp/abbrev.el    2013-04-16 17:28:11 +0000
@@ -669,6 +669,26 @@
       tables))))
 
 
+(defun abbrev--symbol (abbrev table)
+  "Return the symbol representing abbrev named ABBREV in TABLE.
+This symbol's name is ABBREV, but it is not the canonical symbol of that name;
+it is interned in the abbrev-table TABLE rather than the normal obarray.
+The value is nil if that abbrev is not defined."
+  (let* ((case-fold (not (abbrev-table-get table :case-fixed)))
+         ;; In case the table doesn't set :case-fixed but some of the
+         ;; abbrevs do, we have to be careful.
+         (sym
+          ;; First try without case-folding.
+          (or (intern-soft abbrev table)
+              (when case-fold
+                ;; We didn't find any abbrev, try case-folding.
+                (let ((sym (intern-soft (downcase abbrev) table)))
+                  ;; Only use it if it doesn't require :case-fixed.
+                  (and sym (not (abbrev-get sym :case-fixed))
+                       sym))))))
+    (if (symbol-value sym)
+        sym)))
+
 (defun abbrev-symbol (abbrev &optional table)
   "Return the symbol representing abbrev named ABBREV.
 This symbol's name is ABBREV, but it is not the canonical symbol of that name;
@@ -678,23 +698,11 @@
 The default is to try buffer's mode-specific abbrev table, then global table."
   (let ((tables (abbrev--active-tables table))
         sym)
-    (while (and tables (not (symbol-value sym)))
-      (let* ((table (pop tables))
-             (case-fold (not (abbrev-table-get table :case-fixed))))
+    (while (and tables (not sym))
+      (let* ((table (pop tables)))
         (setq tables (append (abbrev-table-get table :parents) tables))
-        ;; In case the table doesn't set :case-fixed but some of the
-        ;; abbrevs do, we have to be careful.
-        (setq sym
-              ;; First try without case-folding.
-              (or (intern-soft abbrev table)
-                  (when case-fold
-                    ;; We didn't find any abbrev, try case-folding.
-                    (let ((sym (intern-soft (downcase abbrev) table)))
-                      ;; Only use it if it doesn't require :case-fixed.
-                      (and sym (not (abbrev-get sym :case-fixed))
-                           sym)))))))
-    (if (symbol-value sym)
-        sym)))
+        (setq sym (abbrev--symbol abbrev table))))
+    sym))
 
 
 (defun abbrev-expansion (abbrev &optional table)
@@ -748,7 +756,7 @@
                            (setq start (match-beginning 1))
                            (setq end   (match-end 1)))))
                      (setq name  (buffer-substring start end))
-                     (let ((abbrev (abbrev-symbol name table)))
+                     (let ((abbrev (abbrev--symbol name table)))
                        (when abbrev
                          (setq enable-fun (abbrev-get abbrev :enable-function))
                          (and (or (not enable-fun) (funcall enable-fun))

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2013-03-30 16:55:47 +0000
+++ b/lisp/progmodes/python.el  2013-04-16 17:28:11 +0000
@@ -2654,8 +2654,8 @@
 (defvar python-skeleton-available '()
   "Internal list of available skeletons.")
 
-(define-abbrev-table 'python-mode-abbrev-table ()
-  "Abbrev table for Python mode."
+(define-abbrev-table 'python-mode-skeleton-abbrev-table ()
+  "Abbrev table for Python mode skeletons."
   :case-fixed t
   ;; Allow / inside abbrevs.
   :regexp "\\(?:^\\|[^/]\\)\\<\\([[:word:]/]+\\)\\W*"
@@ -2668,13 +2668,13 @@
 (defmacro python-skeleton-define (name doc &rest skel)
   "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'."
+be added to `python-mode-skeleton-abbrev-table'."
   (declare (indent 2))
   (let* ((name (symbol-name name))
          (function-name (intern (concat "python-skeleton-" name))))
     `(progn
-       (define-abbrev python-mode-abbrev-table ,name "" ',function-name
-         :system t)
+       (define-abbrev python-mode-skeleton-abbrev-table
+         ,name "" ',function-name :system t)
        (setq python-skeleton-available
              (cons ',function-name python-skeleton-available))
        (define-skeleton ,function-name
@@ -2682,6 +2682,10 @@
               (format "Insert %s statement." name))
          ,@skel))))
 
+(define-abbrev-table 'python-mode-abbrev-table ()
+  "Abbrev table for Python mode."
+  :parents (list python-mode-skeleton-abbrev-table))
+
 (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."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]