GNU bug report logs -
#5937
23.1.95; why saving empty abbrev tables
Previous Next
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 #8 received at 5937 <at> debbugs.gnu.org (full text, mbox):
> 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?
> (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 write-abbrev-file (around nonempty-abbrev-tables activate)
> "Ignore empty abbrev tables when writing to FILE."
> (let ((file (ad-get-arg 0))
> (coding-system-for-write 'emacs-mule)
> (tables (loop for table in abbrev-table-name-list
> unless (abbrev-table-empty-p (symbol-value table))
> collect table)))
> (or (and file (> (length file) 0)) (setq file abbrev-file-name))
> (with-temp-file file
> (insert ";;-*-coding: emacs-mule;-*-\n")
> (dolist (table (sort tables
> (lambda (s1 s2)
> (string< (symbol-name s1)
> (symbol-name s2)))))
> (insert-abbrev-table-description table nil)))))
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".
Stefan
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.