[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5937: 23.1.95; why saving empty abbrev tables

From: Leo
Subject: bug#5937: 23.1.95; why saving empty abbrev tables
Date: Mon, 28 Mar 2011 12:45:47 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7)

On 2011-03-28 04:40 +0800, Stefan Monnier wrote:
> 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?

=== modified file 'lisp/abbrev.el'
--- lisp/abbrev.el      2011-03-22 15:38:40 +0000
+++ lisp/abbrev.el      2011-03-28 04:42:26 +0000
@@ -65,7 +65,8 @@
 (defvar edit-abbrevs-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-x\C-s" 'edit-abbrevs-redefine)
+    (define-key map "\C-x\C-s" 'abbrev-save-buffer)
+    (define-key map "\C-x\C-w" 'write-abbrev-file)
     (define-key map "\C-c\C-c" 'edit-abbrevs-redefine)
   "Keymap used in `edit-abbrevs'.")
@@ -211,13 +212,14 @@
                                        ;(interactive "fRead abbrev file: ")
   (read-abbrev-file file t))
-(defun write-abbrev-file (&optional file)
+(defun write-abbrev-file (&optional file verbose)
   "Write all user-level abbrev definitions to a file of Lisp code.
 This does not include system abbrevs; it includes only the abbrev tables
 listed in listed in `abbrev-table-name-list'.
 The file written can be loaded in another session to define the same abbrevs.
 The argument FILE is the file name to write.  If omitted or nil, the file
-specified in `abbrev-file-name' is used."
+specified in `abbrev-file-name' is used.
+If VERBOSE is non-nil, display a message where abbrevs have been saved."
     (read-file-name "Write abbrev file: "
@@ -225,6 +227,7 @@
   (or (and file (> (length file) 0))
       (setq file abbrev-file-name))
+  (edit-abbrevs-redefine)
   (let ((coding-system-for-write 'utf-8))
       (dolist (table
@@ -247,7 +250,14 @@
       (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))
 (defun add-mode-abbrev (arg)
   "Define mode-specific abbrev for last word(s) before point.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]