From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Luke Blanshard" Newsgroups: gmane.emacs.bugs Subject: dabbrev (still) ignores possibilities that differ by case Date: Mon, 13 May 2002 09:53:03 -0700 Sender: bug-gnu-emacs-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1021308855 19626 127.0.0.1 (13 May 2002 16:54:15 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 13 May 2002 16:54:15 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 177J5S-00056K-00 for ; Mon, 13 May 2002 18:54:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 177J5i-0005pS-00; Mon, 13 May 2002 12:54:30 -0400 Original-Received: from [208.10.43.132] (helo=vpn.west.quiq.com) by fencepost.gnu.org with smtp (Exim 3.34 #1 (Debian)) id 177J4K-0005hu-00 for ; Mon, 13 May 2002 12:53:05 -0400 Original-Received: from nsmail.west.quiq.com (willie.west.quiq.com [192.168.100.51]) by vpn.west.quiq.com (Postfix) with ESMTP id 9DE2B10709 for ; Mon, 13 May 2002 10:06:14 -0700 (PDT) Original-Received: from scratchy.west.quiq.com ([192.168.100.31]) by nsmail.west.quiq.com (Netscape Messaging Server 4.15) with ESMTP id GW26WF00.K1R for ; Mon, 13 May 2002 09:53:03 -0700 Original-To: bug-gnu-emacs@gnu.org Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:1336 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:1336 This bug report will be sent to the Free Software Foundation, not to your local site managers! Please write in English, because the Emacs maintainers do not have translators to read other languages for them. Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list, and to the gnu.emacs.bug news group. In GNU Emacs 21.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2002-05-07 on scratchy.west.quiq.com Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en_US locale-coding-system: iso-latin-1 default-enable-multibyte-characters: t Please describe exactly what actions triggered the bug and the precise symptoms of the bug: I submit this bug every couple of years or so, when I start using a new version of emacs. I never get any acknowledgement that anyone has actually looked at it and disagreed with me; so I presume that I've either failed to explain the situation properly or that my bug reports have just fallen through the cracks. I write code for a living, which (for better or worse) often contains names that mean different things but that differ only by case: for example, "Exception" might be a class name, "exception" might be a variable name, and "EXCEPTION" might be a constant. Hence, I use dabbrev with dabbrev-case-fold-search set to t and dabbrev-case-replace set to nil. In other words, when I type "exc" and hit M-/, I want it to match any of the above spellings of "exception" and drop in whatever it finds without messing with its case. But I also want one other crucial bit of functionality, and this is the bug. I want dabbrev to include ALL VARIANTS OF THIS WORD as it's cycling through its list. Here's how you can see what I mean. Create a new buffer, set your dabbrev variables as I do, and add these three words to the buffer: Exception exception EXCEPTION Then on the next line type "exc" and hit M-/. It will be replaced with "EXCEPTION". Now hit M-/ again. You might see another word, like "except", but you will not see "exception". I believe you should see "EXCEPTION", "exception", and "Exception", in that order, before dabbrev tries any other buffers. What's more, I have a patch for dabbrev.el that accomplishes this goal, quite cleanly (IMHO). It's the same patch I've submitted at least twice before, but this time it's against the new version of dabbrev.el. How about that. Here it is: [scratchy 08:09:49 ~/work/src/java/bugs]$ diff -u /usr/local/share/emacs/21.2/lisp/dabbrev.el ~/elisp/dabbrev.el --- /usr/local/share/emacs/21.2/lisp/dabbrev.el Thu Jun 21 00:40:45 2001 +++ /export/home/luke/elisp/dabbrev.el Mon May 13 09:17:49 2002 @@ -687,7 +687,11 @@ (while (and (> count 0) (setq expansion (dabbrev--search abbrev reverse - ignore-case))) + (and ignore-case + (if (eq dabbrev-case-replace 'case-replace) + case-replace + dabbrev-case-replace)) + ))) (setq count (1- count)))) (and expansion (setq dabbrev--last-expansion-location (point))) @@ -948,7 +952,8 @@ "\\(" dabbrev--abbrev-char-regexp "\\)")) (pattern2 (concat (regexp-quote abbrev) "\\(\\(" dabbrev--abbrev-char-regexp "\\)+\\)")) - (found-string nil)) + (found-string nil) + (result nil)) ;; Limited search. (save-restriction (and dabbrev-limit @@ -972,7 +977,8 @@ ;; We have a truly valid match. Find the end. (re-search-forward pattern2) (setq found-string (buffer-substring-no-properties - (match-beginning 1) (match-end 1))) + (match-beginning 0) (match-end 0))) + (setq result found-string) (and ignore-case (setq found-string (downcase found-string))) ;; Ignore this match if it's already in the table. (if (dabbrev-filter-elements @@ -986,14 +992,11 @@ ;; If we found something, use it. (if found-string ;; Put it into `dabbrev--last-table' - ;; and return it (either downcased, or as is). - (let ((result (buffer-substring-no-properties - (match-beginning 0) (match-end 0)))) + ;; and return its value prior to its possible downcasing. + (progn (setq dabbrev--last-table (cons found-string dabbrev--last-table)) - (if (and ignore-case (eval dabbrev-case-replace)) - result - result))))))) + result)))))) (dolist (mess '("^No dynamic expansion for .* found$" "^No further dynamic expansion for .* found$" I expect the patch to be pretty much self-evident; if it isn't, you can either hunt around for the last times I've submitted it where I explained it in some detail, or you can write to ask me what's going on. I would be happy to do so. Regards, Luke Blanshard Quiq, Inc. Recent input: d a < q y C-x k C-g C-x C-f C-g C-x k M-` t 1 t d a / u s r l / l o c s h e m l i ? 2 l i d a b n n n n b r a C-x u C-x u C-x u p n q y C-h C-h C-g Recent messages: [2 times] Refining difference region 4 ... [2 times] Saving old diff region #4 of buffer A. To recover, type `ra' [2 times] Only white-space differences in region 4 Diff region 4 in buffer A restored Buffer is read-only: # Undo! [2 times] [5 times] Loading emacsbug...done