GNU bug report logs - #5937
23.1.95; why saving empty abbrev tables

Previous Next

Package: emacs;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Mon, 12 Apr 2010 15:24:02 UTC

Severity: minor

Fixed in version 24.1

Done: Leo <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Leo <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5937 <at> debbugs.gnu.org
Subject: bug#5937: 23.1.95; why saving empty abbrev tables
Date: Mon, 28 Mar 2011 12:03:22 +0800
On 2011-03-28 04:35 +0800, Stefan Monnier wrote:
> I don't think we need such a thing.  We just need to make it clear what
> those empty tables mean and keep them out of the way.  I.e. move them to
> the end of the buffer and add a comment before them explaining that
> these are currently empty.

OK let's do this. I didn't insert a line explaining empty tables because
they are obvious (See this screenshot: http://imgur.com/zCegB.png).

(BTW, after looking at that screenshot I realised Makefile mode
introduces 6 abbrev tables; amazing.)

Let me know if you are OK with this patch.

Thanks,
Leo

=== modified file 'lisp/abbrev.el'
--- lisp/abbrev.el	2011-03-22 15:38:40 +0000
+++ lisp/abbrev.el	2011-03-28 03:52:49 +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,18 @@
   (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.






This bug report was last modified 14 years and 116 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.