[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, 27 Apr 2010 11:12:49 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

On 2010-04-27 09:46 +0100, Leo wrote:
> Do you think we can address this issue in another way for example by
> offering a key biding to enter an empty table? For example, make M-RET
> move point to the end of current abbrev table and asking for a table
> name (with completion)? (this is similar to M-RET in org mode)

The attached patch does this. Could you try and see if you like it?

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 21411a5..c27f29a 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -73,8 +73,9 @@ to enable or disable Abbrev mode in the current buffer."
 (defvar edit-abbrevs-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\C-x\C-s" 'edit-abbrevs-redefine)
-    (define-key map "\C-c\C-c" 'edit-abbrevs-redefine)
+    (define-key map "\C-x\C-s"      'edit-abbrevs-redefine)
+    (define-key map "\C-c\C-c"      'edit-abbrevs-redefine)
+    (define-key map [(meta return)] 'edit-abbrevs-new-table-entry)
   "Keymap used in `edit-abbrevs'.")
@@ -175,6 +176,24 @@ or may be omitted (it is usually omitted)."
     (define-abbrevs t)
     (set-buffer-modified-p nil)))
+(defun edit-abbrevs-new-table-entry (tablename)
+  "Enter a new table entry for TABLENAME into current buffer."
+  (interactive
+   (list (intern-soft
+          (completing-read "Table name: "
+                           (mapcar 'symbol-name abbrev-table-name-list)
+                           (lambda (tn)
+                             (abbrev-table-empty-p
+                              (symbol-value (intern-soft tn))))
+                           t))))
+  (or (looking-at "^(.*)$")
+      (and (re-search-forward "^(.*)$" nil t)
+           (goto-char (match-beginning 0)))
+      (goto-char (point-max)))
+  (unless (bolp) (insert "\n"))
+  (insert-abbrev-table-description tablename t)
+  (forward-line -2))
 (defun define-abbrevs (&optional arg)
   "Define abbrevs according to current visible buffer contents.
 See documentation of `edit-abbrevs' for info on the format of the

reply via email to

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