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


Message #11 received at 5937 <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 5937 <at> debbugs.gnu.org
Subject: Re: bug#5937: 23.1.95; why saving empty abbrev tables
Date: Thu, 15 Apr 2010 11:26:55 +0100
On 2010-04-12 19:32 +0100, Stefan Monnier wrote:
>> Why empty abbrev tables are saved to file?
>
> Don't know.
>
>> It seems to make it more difficult for editing (edit-abbrevs) because
>> the buffer is full of empty abbrev.  I wonder if saving only non-empty
>> tables is better and user friendlier.
>
> It does sound like a good idea.  Any objection?

I have been using this in my init file and I like it. It makes it easier
to see what's actually defined.

(defun abbrev-table-empty-p (table)
  "Return nil if there are no abbrev symbols in abbrev table object
  TABLE."
  (unless (abbrev-table-p table)
    (error "Non abbrev table object"))
  (not (catch 'some
         (mapatoms (lambda (sym)
                     (when (abbrev-symbol (symbol-name sym) table)
                       (throw 'some t)))
                   table))))
(defadvice prepare-abbrev-list-buffer (around nonempty-abbrev-tables
  activate)
  "Ignore empty abbrev tables."
  (let ((abbrev-table-name-list
         (loop for table in abbrev-table-name-list
               unless (abbrev-table-empty-p (symbol-value table))
               collect table)))
    ad-do-it))
(defadvice write-abbrev-file (around nonempty-abbrev-tables activate)
  "Ignore empty abbrev tables when writing to FILE."
  (let ((abbrev-table-name-list
         (loop for table in abbrev-table-name-list
               unless (abbrev-table-empty-p (symbol-value table))
               collect table)))
    ad-do-it))

[...]
> Obviously, defadvice wouldn't be the right approach for us.
> And rather than (abbrev-symbol (symbol-name sym) table), we can use
> (symbol-value sym).
> We should also eliminate abbrev tables that only contain "system
> abbrevs".

Regarding the :system property, I have experienced some oddity but I
by-passed that instead of looking into it for lack of time.

Here's what happened.

When I use define-abbrev to define some system abbrevs and then M-x
edit-abbrevs and move to the table where those abbrevs are defined then
paste some non-system abbrevs from, for example, another abbrev file.
Those pasted abbrevs are treated as system abbrevs and not saved.
Sometimes when the table already have non-system abbrevs, they are
turned into system ones and get lost.

I had a backup of the abbrev file so that didn't cause me any trouble.

>
>         Stefan

Leo




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

Previous Next


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