[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: Tue, 29 Mar 2011 23:42:36 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7)

Hopefully this patch is ready to commit.

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 0a3e1fd1..fbc4bdbd 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -73,7 +73,8 @@ (put 'abbrev-mode 'safe-local-variable 'booleanp)
 (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-edit-save-buffer)
+    (define-key map "\C-x\C-w" 'abbrev-edit-save-to-file)
     (define-key map "\C-c\C-c" 'edit-abbrevs-redefine)
   "Keymap used in `edit-abbrevs'.")
@@ -224,13 +225,15 @@ (defun quietly-read-abbrev-file (&optional file)
                                        ;(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 indicating where abbrevs
+have been saved."
     (read-file-name "Write abbrev file: "
@@ -260,7 +263,25 @@ (defun write-abbrev-file (&optional file)
       (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-edit-save-to-file (file)
+  "Save all user-level abbrev definitions in current buffer to FILE."
+  (interactive
+   (list (read-file-name "Save abbrevs to file: "
+                        (file-name-directory
+                         (expand-file-name abbrev-file-name))
+                        abbrev-file-name)))
+  (edit-abbrevs-redefine)
+  (write-abbrev-file file t))
+(defun abbrev-edit-save-buffer ()
+  "Save all user-level abbrev definitions in current buffer.
+The saved abbrevs are written to the file specified by
+  (interactive)
+  (abbrev-edit-save-to-file abbrev-file-name))
 (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]