From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.help Subject: Re: Word Completion by Association Date: 10 Mar 2003 15:09:04 -0500 Organization: Yale University Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <5ladg3nfvj.fsf@rum.cs.yale.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1047328085 15296 80.91.224.249 (10 Mar 2003 20:28:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 10 Mar 2003 20:28:05 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 10 21:27:59 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18sTsN-0003xu-00 for ; Mon, 10 Mar 2003 21:27:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18sTqP-0003Wd-00 for gnu-help-gnu-emacs@m.gmane.org; Mon, 10 Mar 2003 15:25:57 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.utk.edu!news-hog.berkeley.edu!ucberkeley!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: rum.cs.yale.edu User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-Original-NNTP-Posting-Host: rum.cs.yale.edu X-Original-Trace: 10 Mar 2003 15:09:04 -0500, rum.cs.yale.edu Original-Xref: shelby.stanford.edu gnu.emacs.help:110961 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:7460 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:7460 >>>>> "Artist" == Artist 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)