GNU bug report logs -
#13758
24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer
Previous Next
Reported by: Dima Kogan <dima <at> secretsauce.net>
Date: Tue, 19 Feb 2013 10:24:01 UTC
Severity: minor
Tags: patch
Found in version 24.3.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13758 in the body.
You can then email your comments to 13758 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13758
; Package
emacs
.
(Tue, 19 Feb 2013 10:24:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dima Kogan <dima <at> secretsauce.net>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 19 Feb 2013 10:24:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I'm attaching a patch to fix an edge case of (subword-forward). To
reproduce the issue:
1. create a buffer that has an all-caps string such as 'ASDF' at the end
of the buffer. There must not be a newline at the end; the 'F' should
be the last character
2. Go to the start of the buffer, and do (subword-forward).
Observe that the point ends up at the 'F', but it should end up one
character ahead of there. To see more clearly that this is wrong, do
(subword-downcase 1) instead of (subword-forward). This should make all
the characters lowercase, but it misses the last one.
This is happening because (subword-forward) is trying to match the
character after the start of the new subword, but at the end of the
buffer, this character doesn't exist.
[0001-subword-forward-no-longer-gets-confused-by-the-end-o.patch (text/x-diff, inline)]
From c248e56c86d96dac8990880b44b983fd4883b1d9 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Tue, 19 Feb 2013 02:14:26 -0800
Subject: [PATCH] (subword-forward) no longer gets confused by the end of the
buffer
This fixes an edge case of (subword-forward). If the point is at the
start of an all-caps word at the end of the buffer, (subword-forward)
would end up at the last character of the word, NOT past the word, as
it should. This was happening because (subword-forward) was trying to
match the character after the start of the new subword, but at the end
of the buffer, this character didn't exist
---
lisp/progmodes/subword.el | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index 80e632c..a86a29b 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -87,7 +87,7 @@
"Function to call for backward subword movement.")
(defvar subword-forward-regexp
- "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)"
+ "\\W*\\(\\([[:upper:]]*\\(\\W?\\)\\)[[:lower:][:digit:]]*\\)"
"Regexp used by `subword-forward-internal'.")
(defvar subword-backward-regexp
@@ -268,7 +268,16 @@ Optional argument ARG is the same as for `capitalize-word'."
(goto-char
(cond
((< 1 (- (match-end 2) (match-beginning 2)))
- (1- (match-end 2)))
+ ;; if we saw start of subword (capital letters or
+ ;; whitespace)...
+ (if (and (= (match-end 2) (point-max))
+ (= (match-end 2) (match-beginning 3)))
+ ;; ... and we have all-caps at the end of the buffer, the
+ ;; next subword starts at end of buffer...
+ (match-end 2)
+ ;; ... if we're not at the end, we have the position of the
+ ;; 2nd character in the subword, so go back one
+ (1- (match-end 2))))
(t
(match-end 0))))
(forward-word 1)))
--
1.7.10.4
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13758
; Package
emacs
.
(Wed, 17 Jul 2013 21:03:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 13758 <at> debbugs.gnu.org (full text, mbox):
Now that I'm aware of this bug, I run into it all the time in everyday
use of emacs. It is very common for me to hit this in the minibuffer,
where short snippets without a trailing newline are common.
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Mon, 22 Jul 2013 16:27:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Dima Kogan <dima <at> secretsauce.net>
:
bug acknowledged by developer.
(Mon, 22 Jul 2013 16:27:03 GMT)
Full text and
rfc822 format available.
Message #13 received at 13758-done <at> debbugs.gnu.org (full text, mbox):
> I'm attaching a patch to fix an edge case of (subword-forward). To
> reproduce the issue:
Thank you. I installed a slightly different patch, but it does
fundamentally the same.
Should be fixed now,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 20 Aug 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.