unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Short to long form expansion?
Date: Thu, 23 Feb 2006 10:44:17 -0500	[thread overview]
Message-ID: <87u0aq13nw.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: CQJKf.42981$Dn4.35584@newsfe3-gui.ntli.net

> Is there a mode that allows completion of words by taking a short form, and
> comparing it with text in the buffer to deduce a longer form?  e.g.

> in a buffer with

> complete_text
> some-variable-name

> c_t M-RET -> complete_text
> s-v-n M-RET -> some-variable-name

> Anything like that?  I use pabbrev-mode which helps alot with code editing,
> but this little extra would be icing on the cake.

I use dabbrev for that, with the following patch,


        Stefan


--- orig/lisp/dabbrev.el
+++ mod/lisp/dabbrev.el
@@ -958,10 +958,12 @@
 Returns the expansion found, or nil if not found.
 Leaves point at the location of the start of the expansion."
   (save-match-data
-    (let ((pattern1 (concat (regexp-quote abbrev)
-			    "\\(" dabbrev--abbrev-char-regexp "\\)"))
-	  (pattern2 (concat (regexp-quote abbrev)
-			   "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)"))
+    (let ((pattern1 (concat (mapconcat (lambda (c) (regexp-quote (string c)))
+				       abbrev (concat "\\(?:" dabbrev--abbrev-char-regexp "\\)*"))
+			    "\\(?:" dabbrev--abbrev-char-regexp "\\)"))
+	  (pattern2 (concat (mapconcat (lambda (c) (regexp-quote (string c)))
+				       abbrev (concat "\\(?:" dabbrev--abbrev-char-regexp "\\)*"))
+			    "\\(\\(?:" dabbrev--abbrev-char-regexp "\\)+\\)"))
 	  ;; This makes it possible to find matches in minibuffer prompts
 	  ;; even when they are "inviolable".
 	  (inhibit-point-motion-hooks t)

  reply	other threads:[~2006-02-23 15:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21 19:27 Short to long form expansion? Christopher Campbell
2006-02-23 15:44 ` Stefan Monnier [this message]
2006-02-23 22:08   ` Christopher Campbell
2006-02-24 22:04   ` Drew Adams
2006-02-23 22:07 ` Kevin Rodgers
     [not found] ` <mailman.39.1140848322.5016.help-gnu-emacs@gnu.org>
2006-02-27 18:37   ` Christopher Campbell

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87u0aq13nw.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).