diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-07-22 12:25:32 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-07-22 12:25:32 -0400 |
commit | 0ac26976f1da4921fd146851740a73b9185a054b (patch) | |
tree | e4aad312e577af0c433a5ac4c0f121fd0d838eb0 /lisp/progmodes/subword.el | |
parent | 368a85a4dbc324c90b2f3338fc97cc73b4c53222 (diff) | |
download | emacs-0ac26976f1da4921fd146851740a73b9185a054b.tar.gz |
* lisp/progmodes/subword.el: Fix boundary case.
(subword-forward-regexp): Make it a constant. Wrap optional \\W in its
own group.
(subword-backward-regexp): Make it a constant.
(subword-forward-internal): Don't treat a trailing capital as the
beginning of a word.
* test/automated/subword-tests.el: New file.
Fixes: debbugs:13758
Diffstat (limited to 'lisp/progmodes/subword.el')
-rw-r--r-- | lisp/progmodes/subword.el | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index a75bdff27bd..8cf4feb62cb 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el @@ -93,11 +93,11 @@ (defvar subword-backward-function 'subword-backward-internal "Function to call for backward subword movement.") -(defvar subword-forward-regexp - "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" +(defconst subword-forward-regexp + "\\W*\\(\\([[:upper:]]*\\(\\W\\)?\\)[[:lower:][:digit:]]*\\)" "Regexp used by `subword-forward-internal'.") -(defvar subword-backward-regexp +(defconst subword-backward-regexp "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" "Regexp used by `subword-backward-internal'.") @@ -319,7 +319,11 @@ edit them as words. (> (match-end 0) (point))) (goto-char (cond - ((< 1 (- (match-end 2) (match-beginning 2))) + ((and (< 1 (- (match-end 2) (match-beginning 2))) + ;; If we have an all-caps word with no following lower-case or + ;; non-word letter, don't leave the last char (bug#13758). + (not (and (null (match-beginning 3)) + (eq (match-end 2) (match-end 1))))) (1- (match-end 2))) (t (match-end 0)))) |