* bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer
@ 2013-02-19 10:21 Dima Kogan
2013-07-17 21:02 ` bug#13758: Note Dima Kogan
2013-07-22 16:26 ` bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: Dima Kogan @ 2013-02-19 10:21 UTC (permalink / raw)
To: 13758
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1893 bytes --]
From c248e56c86d96dac8990880b44b983fd4883b1d9 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#13758: Note
2013-02-19 10:21 bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Dima Kogan
@ 2013-07-17 21:02 ` Dima Kogan
2013-07-22 16:26 ` bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Dima Kogan @ 2013-07-17 21:02 UTC (permalink / raw)
To: 13758
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer
2013-02-19 10:21 bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Dima Kogan
2013-07-17 21:02 ` bug#13758: Note Dima Kogan
@ 2013-07-22 16:26 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-07-22 16:26 UTC (permalink / raw)
To: Dima Kogan; +Cc: 13758-done
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-22 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-19 10:21 bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Dima Kogan
2013-07-17 21:02 ` bug#13758: Note Dima Kogan
2013-07-22 16:26 ` bug#13758: 24.3.50; [PATCH] fixed (subword-forward) edge case at the end of a buffer Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).