From: Leo Liu <sdl.web@gmail.com> Date: Mon, 28 Mar 2011 14:34:32 +0000 (+0800) Subject: Place empty abbrev tables after nonempty ones when editing X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~468 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=947b656632a76ebb01eda0550c34b1ac43684a98;p=emacs.git Place empty abbrev tables after nonempty ones when editing --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a8838161136..9eeac0d2155 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-28 Leo Liu <sdl.web@gmail.com> + + * 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 <jan.h.d@swipnet.se> * cus-start.el (all): Add boolean ns-auto-hide-menu-bar. diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 3b383a5f5b8..504d9fcbbce 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -123,8 +123,13 @@ Otherwise display all abbrevs." (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 @@ PROPS is a list of properties." (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.