Mercurial > emacs
diff lisp/progmodes/cc-subword.el @ 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 | c1ec1c8a8d2e |
line wrap: on
line diff
--- 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))))