aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-07-22 12:25:32 -0400
committerStefan Monnier2013-07-22 12:25:32 -0400
commit0ac26976f1da4921fd146851740a73b9185a054b (patch)
treee4aad312e577af0c433a5ac4c0f121fd0d838eb0
parent368a85a4dbc324c90b2f3338fc97cc73b4c53222 (diff)
downloademacs-0ac26976f1da4921fd146851740a73b9185a054b.tar.gz
emacs-0ac26976f1da4921fd146851740a73b9185a054b.zip
* 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
-rw-r--r--lisp/ChangeLog21
-rw-r--r--lisp/progmodes/subword.el12
-rw-r--r--test/ChangeLog4
-rw-r--r--test/automated/subword-tests.el49
4 files changed, 76 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 349e6bb7420..bf243febe4f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12013-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * progmodes/subword.el: Fix boundary case (bug#13758).
4 (subword-forward-regexp): Make it a constant. Wrap optional \\W in its
5 own group.
6 (subword-backward-regexp): Make it a constant.
7 (subword-forward-internal): Don't treat a trailing capital as the
8 beginning of a word.
9
12013-07-22 Ari Roponen <ari.roponen@gmail.com> (tiny change) 102013-07-22 Ari Roponen <ari.roponen@gmail.com> (tiny change)
2 11
3 * emacs-lisp/package.el (package-menu-mode): Don't modify the 12 * emacs-lisp/package.el (package-menu-mode): Don't modify the
@@ -10,8 +19,8 @@
10 (desktop--process-minibuffer-frames): Set desktop-mini parameter only 19 (desktop--process-minibuffer-frames): Set desktop-mini parameter only
11 for frames being saved. Rename from desktop--save-minibuffer-frames. 20 for frames being saved. Rename from desktop--save-minibuffer-frames.
12 (desktop-save-frames): Run hook desktop-before-saving-frames-functions. 21 (desktop-save-frames): Run hook desktop-before-saving-frames-functions.
13 Do not save frames with non-nil `desktop-dont-save' parameter. Filter 22 Do not save frames with non-nil `desktop-dont-save' parameter.
14 out deleted frames. 23 Filter out deleted frames.
15 (desktop--find-frame): Use cl-find-if. 24 (desktop--find-frame): Use cl-find-if.
16 (desktop--select-frame): Use cl-(first|second|third) to access values 25 (desktop--select-frame): Use cl-(first|second|third) to access values
17 of desktop-mini. 26 of desktop-mini.
@@ -352,17 +361,17 @@
352 361
353 * net/tramp.el (tramp-current-connection): New defvar, moved from 362 * net/tramp.el (tramp-current-connection): New defvar, moved from
354 tramp-sh.el. 363 tramp-sh.el.
355 (tramp-message-show-progress-reporter-message): Removed, not 364 (tramp-message-show-progress-reporter-message): Remove, not
356 needed anymore. 365 needed anymore.
357 (tramp-error-with-buffer): Show message in minibuffer. Discard 366 (tramp-error-with-buffer): Show message in minibuffer.
358 input before waiting. Reset connection timestamp. 367 Discard input before waiting. Reset connection timestamp.
359 (with-tramp-progress-reporter): Improve messages. 368 (with-tramp-progress-reporter): Improve messages.
360 (tramp-process-actions): Use progress reporter. Delete process in 369 (tramp-process-actions): Use progress reporter. Delete process in
361 case of error. Improve messages. 370 case of error. Improve messages.
362 371
363 * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case. 372 * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case.
364 Call `tramp-error-with-buffer' with vector and buffer. 373 Call `tramp-error-with-buffer' with vector and buffer.
365 (tramp-current-connection): Removed. 374 (tramp-current-connection): Remove.
366 (tramp-maybe-open-connection): The car of 375 (tramp-maybe-open-connection): The car of
367 `tramp-current-connection' are the first 3 slots of the vector. 376 `tramp-current-connection' are the first 3 slots of the vector.
368 377
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 @@
93(defvar subword-backward-function 'subword-backward-internal 93(defvar subword-backward-function 'subword-backward-internal
94 "Function to call for backward subword movement.") 94 "Function to call for backward subword movement.")
95 95
96(defvar subword-forward-regexp 96(defconst subword-forward-regexp
97 "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" 97 "\\W*\\(\\([[:upper:]]*\\(\\W\\)?\\)[[:lower:][:digit:]]*\\)"
98 "Regexp used by `subword-forward-internal'.") 98 "Regexp used by `subword-forward-internal'.")
99 99
100(defvar subword-backward-regexp 100(defconst subword-backward-regexp
101 "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" 101 "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)"
102 "Regexp used by `subword-backward-internal'.") 102 "Regexp used by `subword-backward-internal'.")
103 103
@@ -319,7 +319,11 @@ edit them as words.
319 (> (match-end 0) (point))) 319 (> (match-end 0) (point)))
320 (goto-char 320 (goto-char
321 (cond 321 (cond
322 ((< 1 (- (match-end 2) (match-beginning 2))) 322 ((and (< 1 (- (match-end 2) (match-beginning 2)))
323 ;; If we have an all-caps word with no following lower-case or
324 ;; non-word letter, don't leave the last char (bug#13758).
325 (not (and (null (match-beginning 3))
326 (eq (match-end 2) (match-end 1)))))
323 (1- (match-end 2))) 327 (1- (match-end 2)))
324 (t 328 (t
325 (match-end 0)))) 329 (match-end 0))))
diff --git a/test/ChangeLog b/test/ChangeLog
index d69155a27ff..c36948eec30 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
12013-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * automated/subword-tests.el: New file.
4
12013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org> 52013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org>
2 6
3 * automated/python-tests.el (python-imenu-create-index-2) 7 * automated/python-tests.el (python-imenu-create-index-2)
diff --git a/test/automated/subword-tests.el b/test/automated/subword-tests.el
new file mode 100644
index 00000000000..62c466439d6
--- /dev/null
+++ b/test/automated/subword-tests.el
@@ -0,0 +1,49 @@
1;;; subword-tests.el --- Testing the subword rules
2
3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Keywords:
7
8;; This program is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
12
13;; This program is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21;;; Commentary:
22
23;;
24
25;;; Code:
26
27(require 'ert)
28
29(defconst subword-tests-strings
30 '("ABC^" ;;Bug#13758
31 "ABC^ ABC^Foo^ ABC^-Foo^ toto^ ABC^"))
32
33(ert-deftest subword-tests ()
34 "Test the `subword-mode' rules."
35 (with-temp-buffer
36 (dolist (str subword-tests-strings)
37 (erase-buffer)
38 (insert str)
39 (goto-char (point-min))
40 (while (search-forward "^" nil t)
41 (replace-match ""))
42 (goto-char (point-min))
43 (while (not (eobp))
44 (subword-forward 1)
45 (insert "^"))
46 (should (equal (buffer-string) str)))))
47
48(provide 'subword-tests)
49;;; subword-tests.el ends here