GNU bug report logs -
#74090
31.0.50; Problems with dabbrev-expand
Previous Next
Reported by: Stephen Berman <stephen.berman <at> gmx.net>
Date: Tue, 29 Oct 2024 17:07:02 UTC
Severity: normal
Found in version 31.0.50
Done: Stephen Berman <stephen.berman <at> gmx.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 31 Oct 2024 12:17:06 +0100
with message-id <87o730v7wt.fsf <at> gmx.net>
and subject line Re: bug#74090: 31.0.50; Problems with dabbrev-expand
has caused the debbugs.gnu.org bug report #74090,
regarding 31.0.50; Problems with dabbrev-expand
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
74090: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74090
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
If an expansion found by dabbrev-expand is located in a different buffer
than the buffer from which dabbrev-expand was invoked, the following
kinds of problems can occur:
First problem:
0. emacs -Q
1. Visit (for example) the INSTALL file in the Emacs source tree.
2. Switch to a new buffer (either empty or at least not containing any
text that can be a dabbrev expansion), type into it the string "Ind"
and then type `M-/' (dabbrev-expand), which expands "Ind" to "Indic".
3. Type `SPC M-/'
=> This does not expand the buffer substring "Indic and" but to
"Indicmacs", which is not a string in any live buffer.
A variant of this problem:
After switching to a new buffer replace the rest of step 2 by the
following:
2a. Type `Indic SPC M-/'. This correctly expands to "Indic and".
3. Type `SPC M-/'
=> This does not expand the buffer substring "Indic and Khmer" but to
"Indic and Installation", which is not a string in any live buffer.
Another variant of this problem:
After visiting INSTALL, type `M-x find-library RET dabbrev RET' to visit
the dabbrev.el source file, then switch to a new buffer, e.g. `C-x b a'
and type `M-x emacs-lisp-mode'. Now continue:
2b. Type `Ind SPC M-/'. This expands to "Indicate" and displays the
message "Expansion found in ‘dabbrev.el’".
3b. Type `M-/' to replace the expansion. This now expands to "Indic"
and displays the message "Expansion found in ‘INSTALL’".
4. Type `SPC M-/'
=> This expands as above to "Indicmacs", which is not a string in any
live buffer.
Second problem:
0. emacs -Q
1. Visit (for example) the INSTALL file in the Emacs source tree.
2. Type `C-s Ind M-a C-SPC M-} C-x n n' and at the prompt type SPC to
narrow the buffer to the paragraph containing "Indic".
3. As in step 2 of the first problem, switch to a new buffer, e.g. `C-x
b a' and then type `Ind M-/'. As above, this expands to "Indic".
4. Type `SPC M-/'.
=> This raises the error "Args out of range: #<buffer INSTALL>, #<marker
at 6 in a>, 4886".
These problems also occur if, instead of invoking dabbrev-expand from an
ordinary buffer, you invoke a command that accepts text input in the
minibuffer, e.g `M-%', and then invoke dabbrev-expand from there:
- For the first case, typing `M-% Ind M-/' in the minibuffer expands to
"Indic", but now typing `SPC M-/' expands the string to "Indicon",
which is not a string in INSTALL or any other live buffer.
- For the first variant of the first case, typing `M-% Indic SPC M-/' in
the minibuffer correctly expands to "Indic and", but typing `SPC M-/'
again expands the string to "Indic anduide", which is not a string in
INSTALL or any other live buffer.
- For the second variant of the first case, after visiting INSTALL and
dabbrev.el, in the latter buffer first typing `M-% Ind M-/' in the
minibuffer expands to "Indicate", then typing `M-/' replaces the
expansion with "Indic", and now typing `SPC M-/' expands string to
"Indicon", which is not a string in any live buffer.
- For the second case, after narrowing buffer INSTALL as above, typing
`M-% Ind M-/' expands to "Indic" and then typing SPC M-/' results in
the error "Args out of range: #<buffer INSTALL>, #<marker at 31 in
*Minibuf-1*>, 4886".
(For the record, I'm pretty sure I've encountered the first problem and
its variants in my normal use of Emacs, though I can't recall specific
instances. I don't recall encountering problems with dabbrev-expand
when using query-replace (but I probably seldom use dabbrev-expand with
query-replace); however, a number of times I have hit the
args-out-of-range error on invoking dabbrev-expand in the minibuffer in
todo-mode, and that is what motivated me to debug the problem, which led
to finding the other dabbrev-expand problems and variants. I used
query-replace instead of todo-mode in the above recipes to keep them
simpler by not having to include the additional steps needed to use
todo-mode.)
From my debugging of these problems, I think they arise because the code
in dabbrev-expand that sets up looking for an expansion (either
directly, or after a space, or as a replacement for the current
expansion) wrongly using positions in the buffer from which
dabbrev-expand was invoked instead of the buffer in which the expansion
is found. The attached patch fixes these problems, according to my
tests. The patch includes comments justifying or at least motivating
the changes.
The patch also includes new tests for dabbrev-tests.el, both for the
cases described above as well as for the same operations but confined to
a single buffer, for which the current code yields correct results (the
tests for the problematic cases fail with the current code, of course).
After applying my fix to dabbrev.el all tests pass with `make check' as
well as in a batch run. However, the four "other-buffer" tests fail
when manually running ert in the dabbrev-tests.el buffer, and I don't
know why; from the ERT output it looks like dabbrev-expand is treating
the test file buffer as the current buffer when manually running these
tests, but I don't see how that happens. Another unresolved issue is
with the test dabbrev-expand-test-minibuffer-3: I could only get this to
pass by invoking `dabbrev--reset-global-variables', and I don't know why
that is needed here but not in the other tests. (The patch omits the
two new resource files used in the tests, which are copies of parts of
INSTALL and dabbrev.el from the Emacs sources).
In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.43, cairo version 1.18.2) of 2024-10-29 built on strobelfssd
Repository revision: 9aa186592634212fcdb2dbafdfd0c52a2475ba96
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Linux From Scratch r12.2-17-systemd
Configured using:
'configure -C 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt6/lib/pkgconfig'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
[Message part 4 (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
On Thu, 31 Oct 2024 12:47:49 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> Cc: 74090 <at> debbugs.gnu.org
>> Date: Thu, 31 Oct 2024 11:39:08 +0100
>>
>> On Thu, 31 Oct 2024 11:20:30 +0100 Stephen Berman <stephen.berman <at> gmx.net> wrote:
>>
>> > On Thu, 31 Oct 2024 12:09:04 +0200 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> >
>> >>> From: Stephen Berman <stephen.berman <at> gmx.net>
>> >>> Cc: 74090 <at> debbugs.gnu.org
>> >>> Date: Thu, 31 Oct 2024 11:00:17 +0100
>> >>>
>> >>> > Thanks, feel free to install on the emacs-30 branch.
>> >>> >
>> >>> >> + ;; Comparing with point only makes sense in the buffer
>> >>> >> + ;; where we called dabbrev-exand, but if that differs
>> >>> > ^^^^^^^^^^^^^
>> >>> > Typo.
>> >>>
>> >>> Thanks, typo corrected and pushed as commit f6c359cb66a -- but to
>> >>> master, I just now noticed that you said emacs-30. I tried reverting
>> >>> but I don't know how. What should I do? Sorry for the snafu.
>> >>
>> >> Instead of reverting, simply cherry-pick it to emacs-30.
>> >
>> > I don't want to screw up again; do I enter exactly the following in the
>> > shell (from the emacs-30 directory)?
>> >
>> > git cherry-pick master
>>
>> My commit to master is no longer the most recent, so should I use this
>> instead?
>>
>> git cherry-pick master f6c359cb66a
>
> Just make sure emacs-30 is the current branch, and then type
>
> $ git cherry-pick -x f6c359cb66a
>
> Then "git show" to eyeball the change, and "git push" to push
> upstream.
Thanks, that worked. And with that I'm closing the bug.
Steve Berman
This bug report was last modified 229 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.