* 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
This commit is contained in:
parent
368a85a4db
commit
0ac26976f1
4 changed files with 76 additions and 10 deletions
|
@ -1,3 +1,12 @@
|
|||
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)
|
||||
|
||||
* emacs-lisp/package.el (package-menu-mode): Don't modify the
|
||||
|
@ -10,8 +19,8 @@
|
|||
(desktop--process-minibuffer-frames): Set desktop-mini parameter only
|
||||
for frames being saved. Rename from desktop--save-minibuffer-frames.
|
||||
(desktop-save-frames): Run hook desktop-before-saving-frames-functions.
|
||||
Do not save frames with non-nil `desktop-dont-save' parameter. Filter
|
||||
out deleted frames.
|
||||
Do not save frames with non-nil `desktop-dont-save' parameter.
|
||||
Filter out deleted frames.
|
||||
(desktop--find-frame): Use cl-find-if.
|
||||
(desktop--select-frame): Use cl-(first|second|third) to access values
|
||||
of desktop-mini.
|
||||
|
@ -352,17 +361,17 @@
|
|||
|
||||
* net/tramp.el (tramp-current-connection): New defvar, moved from
|
||||
tramp-sh.el.
|
||||
(tramp-message-show-progress-reporter-message): Removed, not
|
||||
(tramp-message-show-progress-reporter-message): Remove, not
|
||||
needed anymore.
|
||||
(tramp-error-with-buffer): Show message in minibuffer. Discard
|
||||
input before waiting. Reset connection timestamp.
|
||||
(tramp-error-with-buffer): Show message in minibuffer.
|
||||
Discard input before waiting. Reset connection timestamp.
|
||||
(with-tramp-progress-reporter): Improve messages.
|
||||
(tramp-process-actions): Use progress reporter. Delete process in
|
||||
case of error. Improve messages.
|
||||
|
||||
* net/tramp-sh.el (tramp-barf-if-no-shell-prompt): Use condition-case.
|
||||
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-current-connection' are the first 3 slots of the vector.
|
||||
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
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>
|
||||
|
||||
* automated/python-tests.el (python-imenu-create-index-2)
|
||||
|
|
49
test/automated/subword-tests.el
Normal file
49
test/automated/subword-tests.el
Normal file
|
@ -0,0 +1,49 @@
|
|||
;;; 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
|
Loading…
Add table
Reference in a new issue