all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Leo <sdl.web@gmail.com>
To: bug-gnu-emacs@gnu.org
Subject: bug#5937: 23.1.95; why saving empty abbrev tables
Date: Tue, 27 Apr 2010 11:12:49 +0100	[thread overview]
Message-ID: <xbai39yhnqzi.fsf@cam.ac.uk> (raw)
In-Reply-To: <m1mxx8lmnz.fsf@cam.ac.uk>

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."
 \f
 (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)
     map)
   "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	other threads:[~2010-04-27 10:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-12 15:23 bug#5937: 23.1.95; why saving empty abbrev tables Leo
2010-04-12 18:32 ` Stefan Monnier
2010-04-15 10:26   ` Leo
2010-04-15 12:44     ` Stefan Monnier
2010-04-16 10:36   ` Leo
2010-04-27  3:49     ` Stefan Monnier
2010-04-27  8:46       ` Leo
2010-04-27 10:12         ` Leo [this message]
2010-04-27 10:32         ` Leo
2011-03-27 20:40           ` Stefan Monnier
2011-03-28  4:45             ` Leo
2011-03-28 13:58               ` Stefan Monnier
2011-03-28 14:26                 ` Leo
2011-03-28 15:09                   ` Stefan Monnier
2011-03-29  0:35                     ` Leo
2011-03-29  3:31                       ` Stefan Monnier
2011-03-29  4:41                         ` Leo
2011-03-29  5:16                           ` Leo
2011-03-29 13:49                             ` Stefan Monnier
2011-03-29 15:42                               ` Leo
2011-03-29 20:54                                 ` Stefan Monnier
2011-03-30  1:08                                   ` Leo
2011-03-27  5:09       ` Leo
2011-03-27 17:34         ` Andreas Röhler
2011-03-28  3:38           ` Leo
2011-03-27 20:35         ` Stefan Monnier
2011-03-28  4:03           ` Leo
2011-03-28 14:02             ` Stefan Monnier
2011-03-28 14:40               ` Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xbai39yhnqzi.fsf@cam.ac.uk \
    --to=sdl.web@gmail.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.