diff --git a/lisp/abbrev.el b/lisp/abbrev.el index b72bdbb..21411a5 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -127,15 +127,20 @@ Otherwise display all abbrevs." (defun prepare-abbrev-list-buffer (&optional local) (with-current-buffer (get-buffer-create "*Abbrevs*") (erase-buffer) - (if local - (insert-abbrev-table-description - (abbrev-table-name local-abbrev-table) t) - (dolist (table abbrev-table-name-list) - (insert-abbrev-table-description table t))) - (goto-char (point-min)) - (set-buffer-modified-p nil) - (edit-abbrevs-mode) - (current-buffer))) + (let ((abbrev-table-name-list + (delete nil (mapcar (lambda (tn) + (unless (abbrev-table-empty-p (symbol-value tn)) + tn)) + abbrev-table-name-list)))) + (if local + (insert-abbrev-table-description + (abbrev-table-name local-abbrev-table) t) + (dolist (table abbrev-table-name-list) + (insert-abbrev-table-description table t))) + (goto-char (point-min)) + (set-buffer-modified-p nil) + (edit-abbrevs-mode) + (current-buffer)))) (defun edit-abbrevs-mode () "Major mode for editing the list of abbrev definitions. @@ -232,7 +237,12 @@ specified in `abbrev-file-name' is used." abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) - (let ((coding-system-for-write 'emacs-mule)) + (let ((coding-system-for-write 'emacs-mule) + (tables (delete nil (mapcar + (lambda (tn) + (unless (abbrev-table-empty-p (symbol-value tn)) + tn)) + abbrev-table-name-list)))) (with-temp-file file (insert ";;-*-coding: emacs-mule;-*-\n") (dolist (table @@ -242,10 +252,9 @@ specified in `abbrev-file-name' is used." ;; user keeps their home directory in a revision ;; control system, and is therefore keeping multiple ;; slightly-differing copies loosely synchronized. - (sort (copy-sequence abbrev-table-name-list) - (lambda (s1 s2) - (string< (symbol-name s1) - (symbol-name s2))))) + (sort tables (lambda (s1 s2) + (string< (symbol-name s1) + (symbol-name s2))))) (insert-abbrev-table-description table nil))))) (defun add-mode-abbrev (arg) @@ -419,6 +428,16 @@ PROPS is a list of properties." (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object) + "Return nil if there are no abbrev symbols in OBJECT." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (sym) + (when (symbol-value sym) + (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.