help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Short to long form expansion?


From: Stefan Monnier
Subject: Re: Short to long form expansion?
Date: Thu, 23 Feb 2006 10:44:17 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> 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 via email to

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