From: Masatake YAMATO Date: Mon, 9 Apr 2007 13:01:30 +0000 (+0000) Subject: (c-capitalize-subword): Implement X-Git-Tag: emacs-pretest-22.0.98~176 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=11d13e96b0dfebc7664ec66030b6b5779485fcb8;p=emacs.git (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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 473cb45cf28..b9ed400e30a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2007-04-09 Masatake YAMATO + + * 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 (tiny change) * progmodes/cc-subword.el (c-downcase-subword, c-upcase-subword): diff --git a/lisp/progmodes/cc-subword.el b/lisp/progmodes/cc-subword.el index 9bdd991982b..a6a365d316b 100644 --- a/lisp/progmodes/cc-subword.el +++ b/lisp/progmodes/cc-subword.el @@ -246,18 +246,23 @@ See the command `c-subword-mode' for a description of subwords. 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))))