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

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

Re: Word Completion by Association


From: Stefan Monnier
Subject: Re: Word Completion by Association
Date: 10 Mar 2003 15:09:04 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>>> "Artist" == Artist  <address@hidden> writes:
> Hi I am looking for mechanism which allows me to complete the word
> based on association.  Example: I have only 4 words : [artist],
> [google], [emacs], [gnu]

How about the following quick hack for a start ?
It changes the behavior of dabbrev along the lines of what you're
asking.  Obviously, we'd want this without losing the old behavior,
but that's for "future work".


        Stefan


--- dabbrev.el.~1.67.~  Wed Feb  5 10:54:43 2003
+++ dabbrev.el  Mon Mar 10 15:07:04 2003
@@ -972,10 +969,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]