emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r103768: Place empty abbrev tables af


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103768: Place empty abbrev tables after nonempty ones when editing
Date: Mon, 28 Mar 2011 22:34:32 +0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103768
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Mon 2011-03-28 22:34:32 +0800
message:
  Place empty abbrev tables after       nonempty ones when editing
modified:
  lisp/ChangeLog
  lisp/abbrev.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-03-27 10:55:07 +0000
+++ b/lisp/ChangeLog    2011-03-28 14:34:32 +0000
@@ -1,3 +1,9 @@
+2011-03-28  Leo Liu  <address@hidden>
+
+       * abbrev.el (abbrev-table-empty-p): New function.
+       (prepare-abbrev-list-buffer): Place empty abbrev tables after
+       nonempty ones.  (Bug#5937)
+
 2011-03-27  Jan Djärv  <address@hidden>
 
        * cus-start.el (all): Add boolean ns-auto-hide-menu-bar.

=== modified file 'lisp/abbrev.el'
--- a/lisp/abbrev.el    2011-03-22 15:38:40 +0000
+++ b/lisp/abbrev.el    2011-03-28 14:34:32 +0000
@@ -123,8 +123,13 @@
       (if local
           (insert-abbrev-table-description
            (abbrev-table-name local-table) t)
-        (dolist (table abbrev-table-name-list)
-          (insert-abbrev-table-description table t)))
+        (let (empty-tables)
+         (dolist (table abbrev-table-name-list)
+           (if (abbrev-table-empty-p (symbol-value table))
+               (push table empty-tables)
+             (insert-abbrev-table-description table t)))
+         (dolist (table (nreverse empty-tables))
+           (insert-abbrev-table-description table t))))
       (goto-char (point-min))
       (set-buffer-modified-p nil)
       (edit-abbrevs-mode)
@@ -420,6 +425,19 @@
   (and (vectorp object)
        (numberp (abbrev-table-get object :abbrev-table-modiff))))
 
+(defun abbrev-table-empty-p (object &optional ignore-system)
+  "Return nil if there are no abbrev symbols in OBJECT.
+If IGNORE-SYSTEM is non-nil, system definitions are ignored."
+  (unless (abbrev-table-p object)
+    (error "Non abbrev table object"))
+  (not (catch 'some
+        (mapatoms (lambda (abbrev)
+                    (unless (or (zerop (length (symbol-name abbrev)))
+                                (and ignore-system
+                                     (abbrev-get abbrev :system)))
+                      (throw 'some t)))
+                  object))))
+
 (defvar global-abbrev-table (make-abbrev-table)
   "The abbrev table whose abbrevs affect all buffers.
 Each buffer may also have a local abbrev table.


reply via email to

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