emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r103777: Improve key bindings in edit


From: Leo Liu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103777: Improve key bindings in edit-abbrevs-mode
Date: Wed, 30 Mar 2011 09:06:00 +0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103777
committer: Leo Liu <address@hidden>
branch nick: trunk
timestamp: Wed 2011-03-30 09:06:00 +0800
message:
  Improve key bindings in edit-abbrevs-mode
  
  C-x C-s and C-x C-w in edit-abbrevs-mode now do something similar to
  their corresponding global bindings.
modified:
  lisp/ChangeLog
  lisp/abbrev.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-03-29 18:26:01 +0000
+++ b/lisp/ChangeLog    2011-03-30 01:06:00 +0000
@@ -1,3 +1,10 @@
+2011-03-30  Leo Liu  <address@hidden>
+
+       * abbrev.el (abbrev-edit-save-to-file, abbrev-edit-save-buffer):
+       New commands.
+       (edit-abbrevs-map): Bind them here.
+       (write-abbrev-file): New optinal arg VERBOSE.  (Bug#5937)
+
 2011-03-29  Ken Manheimer  <address@hidden>
 
        * allout.el (allout-hide-by-annotation, allout-flag-region):

=== modified file 'lisp/abbrev.el'
--- a/lisp/abbrev.el    2011-03-28 14:34:32 +0000
+++ b/lisp/abbrev.el    2011-03-30 01:06:00 +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-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)
     map)
   "Keymap used in `edit-abbrevs'.")
@@ -216,13 +217,15 @@
                                        ;(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."
   (interactive
    (list
     (read-file-name "Write abbrev file: "
@@ -252,7 +255,25 @@
                '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-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
+`abbrev-file-name'."
+  (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]