From: Leo <sdl.web@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#5937: 23.1.95; why saving empty abbrev tables
Date: Fri, 16 Apr 2010 11:36:21 +0100 [thread overview]
Message-ID: <xbaityrbr8ey.fsf@cam.ac.uk> (raw)
In-Reply-To: <m1mxx8lmnz.fsf@cam.ac.uk>
[-- Attachment #1: Type: text/plain, Size: 465 bytes --]
On 2010-04-12 19:32 +0100, Stefan Monnier wrote:
>> 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?
Would the following patch be acceptable?
* lisp/abbrev.el (write-abbrev-file prepare-abbrev-list-buffer):
ignore empty abbrev tables
(abbrev-table-empty-p): new function.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: abbrev.diff --]
[-- Type: text/x-patch, Size: 3284 bytes --]
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)))))
\f
(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.
[-- Attachment #3: Type: text/plain, Size: 13 bytes --]
Thanks,
Leo
next prev parent reply other threads:[~2010-04-16 10:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-12 15:23 bug#5937: 23.1.95; why saving empty abbrev tables Leo
2010-04-12 18:32 ` Stefan Monnier
2010-04-15 10:26 ` Leo
2010-04-15 12:44 ` Stefan Monnier
2010-04-16 10:36 ` Leo [this message]
2010-04-27 3:49 ` Stefan Monnier
2010-04-27 8:46 ` Leo
2010-04-27 10:12 ` Leo
2010-04-27 10:32 ` Leo
2011-03-27 20:40 ` Stefan Monnier
2011-03-28 4:45 ` Leo
2011-03-28 13:58 ` Stefan Monnier
2011-03-28 14:26 ` Leo
2011-03-28 15:09 ` Stefan Monnier
2011-03-29 0:35 ` Leo
2011-03-29 3:31 ` Stefan Monnier
2011-03-29 4:41 ` Leo
2011-03-29 5:16 ` Leo
2011-03-29 13:49 ` Stefan Monnier
2011-03-29 15:42 ` Leo
2011-03-29 20:54 ` Stefan Monnier
2011-03-30 1:08 ` Leo
2011-03-27 5:09 ` Leo
2011-03-27 17:34 ` Andreas Röhler
2011-03-28 3:38 ` Leo
2011-03-27 20:35 ` Stefan Monnier
2011-03-28 4:03 ` Leo
2011-03-28 14:02 ` Stefan Monnier
2011-03-28 14:40 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xbaityrbr8ey.fsf@cam.ac.uk \
--to=sdl.web@gmail.com \
--cc=bug-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.