emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113492: * lisp/progmodes/subword.el: Fix boundary c


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r113492: * lisp/progmodes/subword.el: Fix boundary case.
Date: Mon, 22 Jul 2013 16:26:08 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113492
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13758
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Mon 2013-07-22 12:25:32 -0400
message:
  * 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.
added:
  test/automated/subword-tests.el 
subwordtests.el-20130722162117-85rw2bafj01fp6dh-1
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/subword.el      subword.el-20091121171556-bypaf8oo9ygoo13w-1
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-07-22 11:39:32 +0000
+++ b/lisp/ChangeLog    2013-07-22 16:25:32 +0000
@@ -1,3 +1,12 @@
+2013-07-22  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>  (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.
 

=== modified file 'lisp/progmodes/subword.el'
--- a/lisp/progmodes/subword.el 2013-05-17 23:18:15 +0000
+++ b/lisp/progmodes/subword.el 2013-07-22 16:25:32 +0000
@@ -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 @@
          (> (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))))

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2013-07-13 01:55:58 +0000
+++ b/test/ChangeLog    2013-07-22 16:25:32 +0000
@@ -1,3 +1,7 @@
+2013-07-22  Stefan Monnier  <address@hidden>
+
+       * automated/subword-tests.el: New file.
+
 2013-07-13  Fabián Ezequiel Gallina  <address@hidden>
 
        * automated/python-tests.el (python-imenu-create-index-2)

=== added file 'test/automated/subword-tests.el'
--- a/test/automated/subword-tests.el   1970-01-01 00:00:00 +0000
+++ b/test/automated/subword-tests.el   2013-07-22 16:25:32 +0000
@@ -0,0 +1,49 @@
+;;; subword-tests.el --- Testing the subword rules
+
+;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
+
+;; Author: Stefan Monnier <address@hidden>
+;; 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]