Subject: bug#5937: 23.1.95; why saving empty abbrev tables

From: Stefan Monnier <[email-masked]>
Date: Mon, 28 Mar 2011 09:58:09 -0400

>> You mean keep C-c C-c bound to edit-abbrevs-redefine, but change C-x C-s
>> to call write-abbrev-file?  Sounds good (tho it'll have to call
>> edit-abbrevs-redefine before write-abbrev-file beforehand, of course).
>> Oh and by the way: the abbrev.el file should be (slowly) fixed to use
>> the "abbrev-" prefix for all functions and commands, so whenever you
>> introduce a new function/command/variable please use this prefix rather
>> than the previous style of <verb>-abbrev-<thing>.
> How about this patch?

> @@ -225,6 +227,7 @@
>  		    abbrev-file-name)))
>    (or (and file (> (length file) 0))
>        (setq file abbrev-file-name))
> +  (edit-abbrevs-redefine)
>    (let ((coding-system-for-write 'utf-8))
>      (with-temp-buffer
>        (dolist (table
> @@ -247,7 +250,14 @@
>  		'emacs-mule)))
>        (goto-char (point-min))
>        (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write))
> -      (write-region nil nil file nil 0))))
> +      (write-region nil nil file nil (and (not verbose) 0)))))
> +
> +(defun abbrev-save-buffer ()
> +  "Save all user-level abbrev definitions in current buffer.
> +The file name to use is `abbrev-file-name'."
> +  (interactive)
> +  (write-abbrev-file abbrev-file-name t))

write-abbrev-file may be called from a non-"edit-abbrevs" buffer
(e.g. from save-some-buffer), so I think that calling
edit-abbrevs-redefine from it is problematic.  Is there a particular
reason why you put the call to edit-abbrevs-redefine in
write-abbrev-file rather than in abbrev-save-buffer.

        Stefan