changeset 77083:304a180098d2

(c-capitalize-subword): Implement better mimic the behavior of `capitalize-word'. They no longer move point with a negative argument. Based on code by Paul Curry.
author Masatake YAMATO <jet@gyve.org>
date Mon, 09 Apr 2007 13:01:30 +0000
parents c783ccac00cf
children e4064040a3af
files lisp/ChangeLog lisp/progmodes/cc-subword.el
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Apr 09 12:34:57 2007 +0000
+++ b/lisp/ChangeLog	Mon Apr 09 13:01:30 2007 +0000
@@ -1,3 +1,10 @@
+2007-04-09  Masatake YAMATO  <jet@gyve.org>
+
+	* progmodes/cc-subword.el (c-capitalize-subword): Implement
+	better mimic the behavior of `capitalize-word'. They no longer 
+	move point with a  negative argument. 
+	Based on code by Paul Curry.
+
 2007-04-09  Paul Curry <dashteacup@gmail.com>  (tiny change)
 
 	* progmodes/cc-subword.el (c-downcase-subword, c-upcase-subword): 
--- a/lisp/progmodes/cc-subword.el	Mon Apr 09 12:34:57 2007 +0000
+++ b/lisp/progmodes/cc-subword.el	Mon Apr 09 13:01:30 2007 +0000
@@ -246,18 +246,23 @@
 Optional argument ARG is the same as for `capitalize-word'."
   (interactive "p")
   (let ((count (abs arg))
-	(direction (if (< 0 arg) 1 -1)))
+	(start (point))
+	(advance (if (< arg 0) nil t)))
     (dotimes (i count)
-      (when (re-search-forward
-	     (concat "[" c-alpha "]")
-	     nil t)
-	(goto-char (match-beginning 0)))
+      (if advance
+	  (progn (re-search-forward
+		  (concat "[" c-alpha "]")
+		  nil t)
+		 (goto-char (match-beginning 0)))
+	(c-backward-subword))
       (let* ((p (point))
 	     (pp (1+ p))
-	     (np (c-forward-subword direction)))
+	     (np (c-forward-subword)))
 	(upcase-region p pp)
 	(downcase-region pp np)
-	(goto-char np)))))
+	(goto-char (if advance np p))))
+    (unless advance
+      (goto-char start))))