all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dabbrev (still) ignores possibilities that differ by case
@ 2002-05-13 16:53 Luke Blanshard
  2002-05-15 15:26 ` Kai Großjohann
  0 siblings, 1 reply; 2+ messages in thread
From: Luke Blanshard @ 2002-05-13 16:53 UTC (permalink / raw)


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 <tab> < <tab> <return> <return> q y <switch-frame> 
<switch-frame> C-x k C-g C-x C-f C-g C-x k <return> 
<switch-frame> <switch-frame> <switch-frame> M-` t 
1 t d a <tab> <return> / u s r l <backspace> / l o 
c <tab> s h <tab> e m <tab> l i <tab> <backspace> <backspace> 
? 2 <tab> l i <tab> d a b <tab> <return> n n n n b 
r a C-x u <switch-frame> <C-tab> C-x u C-x u <switch-frame> 
p n q y <switch-frame> <switch-frame> C-h C-h C-g <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <menu-bar> <help-menu> <re
port-emacs-bug>

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: #<buffer *Ediff Control Panel*>
Undo! [2 times]
 [5 times]
Loading emacsbug...done

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dabbrev (still) ignores possibilities that differ by case
  2002-05-13 16:53 dabbrev (still) ignores possibilities that differ by case Luke Blanshard
@ 2002-05-15 15:26 ` Kai Großjohann
  0 siblings, 0 replies; 2+ messages in thread
From: Kai Großjohann @ 2002-05-15 15:26 UTC (permalink / raw)


"Luke Blanshard" <luke@quiq.com> writes:

> 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.

I think the idea is that you are supposed to type exc M-/ if you want
"exception" but to type Exc M-/ if you want "Exception", and EXC M-/
if you want "EXCEPTION".

But the feature you want would surely be useful.

kai
-- 
Silence is foo!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-05-15 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-13 16:53 dabbrev (still) ignores possibilities that differ by case Luke Blanshard
2002-05-15 15:26 ` Kai Großjohann

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.