[Top][All Lists]

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

RE: isearch.el patch for `M-e' to put point at mismatch position

From: Drew Adams
Subject: RE: isearch.el patch for `M-e' to put point at mismatch position
Date: Sat, 10 Sep 2011 09:13:18 -0700

> > When you hit `M-e' you are ready to edit at the mismatch 
> > position.  This makes it easy to change or insert a char
> > or two to make the string match.  (`C-g', on
> > the other hand just removes all of the mismatch.)
> I discovered now that you can't mix `isearch-message' and 
> `isearch-string'.
> Test case to reproduce the bug:
> 1. emacs -Q
> 2. insert a few TABs with e.g. `C-q TAB C-q TAB C-q TAB'
> 3. `M-<' (`beginning-of-buffer')
> 4. `C-s C-q TAB M-e'
> fails with the error message "End of buffer".

Good catch.

> The reason is that `isearch-message' is longer than `isearch-string',
> because `isearch-text-char-description' replaces a single TAB
> with two characters "^I" in `isearch-message'.
> `isearch-fail-pos' calculates the position based on 
> `isearch-message', but uses it for `isearch-string' in
> `(cons isearch-string (1+ (isearch-fail-pos)))' in
> `isearch-edit-string'.
> Replacing `isearch-message' with `isearch-string' in 
> `isearch-fail-pos' will fix this bug.

Sounds good.  Please go for it.

> BTW, there is exactly the same algorithm used in two functions
> `isearch-fail-pos' and `isearch-message'.

Well, not exactly, but close.

> Currently both functions use the same variable `isearch-message',
> but after this fix the same algorithm
> will use different variables `isearch-message' and `isearch-string'.
> So sharing code between them will be more difficult.

There's no real need to share code between them.

> Maybe it would be better to add a new argument to `isearch-fail-pos'
> that will define whether it should return the failed position in
> `isearch-message' or `isearch-string'?

That might be OK too, but I'd suggest just making your suggested change above:
replace `isearch-message' with `isearch-string' in `isearch-fail-pos'.

reply via email to

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