Commit 0ac26976 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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
parent 368a85a4
2013-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
* progmodes/subword.el: Fix boundary case (bug#13758).
(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.
2013-07-22 Ari Roponen <ari.roponen@gmail.com> (tiny change) 2013-07-22 Ari Roponen <ari.roponen@gmail.com> (tiny change)
* emacs-lisp/package.el (package-menu-mode): Don't modify the * emacs-lisp/package.el (package-menu-mode): Don't modify the
...@@ -10,8 +19,8 @@ ...@@ -10,8 +19,8 @@
(desktop--process-minibuffer-frames): Set desktop-mini parameter only (desktop--process-minibuffer-frames): Set desktop-mini parameter only
for frames being saved. Rename from desktop--save-minibuffer-frames. for frames being saved. Rename from desktop--save-minibuffer-frames.
(desktop-save-frames): Run hook desktop-before-saving-frames-functions. (desktop-save-frames): Run hook desktop-before-saving-frames-functions.
Do not save frames with non-nil `desktop-dont-save' parameter. Filter Do not save frames with non-nil `desktop-dont-save' parameter.
out deleted frames. Filter out deleted frames.
(desktop--find-frame): Use cl-find-if. (desktop--find-frame): Use cl-find-if.
(desktop--select-frame): Use cl-(first|second|third) to access values (desktop--select-frame): Use cl-(first|second|third) to access values
of desktop-mini. of desktop-mini.
...@@ -352,17 +361,17 @@ ...@@ -352,17 +361,17 @@
* net/tramp.el (tramp-current-connection): New defvar, moved from * net/tramp.el (tramp-current-connection): New defvar, moved from
tramp-sh.el. tramp-sh.el.
(tramp-message-show-progress-reporter-message): Removed, not (tramp-message-show-progress-reporter-message): Remove, not
needed anymore. needed anymore.
(tramp-error-with-buffer): Show message in minibuffer. Discard (tramp-error-with-buffer): Show message in minibuffer.
input before waiting. Reset connection timestamp. Discard input before waiting. Reset connection timestamp.
(with-tramp-progress-reporter): Improve messages. (with-tramp-progress-reporter): Improve messages.
(tramp-process-actions): Use progress reporter. Delete process in (tramp-process-actions): Use progress reporter. Delete process in
case of error. Improve messages. case of error. Improve messages.
* net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case. * net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case.
Call `tramp-error-with-buffer' with vector and buffer. Call `tramp-error-with-buffer' with vector and buffer.
(tramp-current-connection): Removed. (tramp-current-connection): Remove.
(tramp-maybe-open-connection): The car of (tramp-maybe-open-connection): The car of
`tramp-current-connection' are the first 3 slots of the vector. `tramp-current-connection' are the first 3 slots of the vector.
......
...@@ -93,11 +93,11 @@ ...@@ -93,11 +93,11 @@
(defvar subword-backward-function 'subword-backward-internal (defvar subword-backward-function 'subword-backward-internal
"Function to call for backward subword movement.") "Function to call for backward subword movement.")
(defvar subword-forward-regexp (defconst subword-forward-regexp
"\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)" "\\W*\\(\\([[:upper:]]*\\(\\W\\)?\\)[[:lower:][:digit:]]*\\)"
"Regexp used by `subword-forward-internal'.") "Regexp used by `subword-forward-internal'.")
(defvar subword-backward-regexp (defconst subword-backward-regexp
"\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)" "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)\\|\\W\\w+\\)"
"Regexp used by `subword-backward-internal'.") "Regexp used by `subword-backward-internal'.")
...@@ -319,7 +319,11 @@ edit them as words. ...@@ -319,7 +319,11 @@ edit them as words.
(> (match-end 0) (point))) (> (match-end 0) (point)))
(goto-char (goto-char
(cond (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))) (1- (match-end 2)))
(t (t
(match-end 0)))) (match-end 0))))
......
2013-07-22 Stefan Monnier <monnier@iro.umontreal.ca>
* automated/subword-tests.el: New file.
2013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org> 2013-07-13 Fabián Ezequiel Gallina <fgallina@gnu.org>
* automated/python-tests.el (python-imenu-create-index-2) * automated/python-tests.el (python-imenu-create-index-2)
......
;;; subword-tests.el --- Testing the subword rules
;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords:
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'ert)
(defconst subword-tests-strings
'("ABC^" ;;Bug#13758
"ABC^ ABC^Foo^ ABC^-Foo^ toto^ ABC^"))
(ert-deftest subword-tests ()
"Test the `subword-mode' rules."
(with-temp-buffer
(dolist (str subword-tests-strings)
(erase-buffer)
(insert str)
(goto-char (point-min))
(while (search-forward "^" nil t)
(replace-match ""))
(goto-char (point-min))
(while (not (eobp))
(subword-forward 1)
(insert "^"))
(should (equal (buffer-string) str)))))
(provide 'subword-tests)
;;; subword-tests.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment