* c-subword-mode - inconsistent behavior
@ 2007-04-02 20:46 Paul Curry
0 siblings, 0 replies; only message in thread
From: Paul Curry @ 2007-04-02 20:46 UTC (permalink / raw)
To: bug-gnu-emacs
The functions c-capitalize-subword, c-downcase-subword, c-upcase-subword
claim to behave like their normal emacs counterparts, but all three
functions move the point when given a negative argument. Furthermore,
c-capitalize-subword doesn't even work with a negative argument on my
machine. I changed the functions to better mimic the behavior of
capitalize/downcase/upcase/-word: they no longer move point with a
negative
argument.
Here's my code:
(defun c-capitalize-subword (arg)
"Do the same as `capitalize-word' but on subwords.
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))
(start (point)))
(dotimes (i count)
(when (if (< arg 0)
(re-search-backward
(concat "\\<[" c-alpha "]")
nil t)
(re-search-forward
(concat "[" c-alpha "]")
nil t))
(goto-char (match-beginning 0)))
(let* ((p (point))
(pp (1+ p))
(np (c-forward-subword)))
(upcase-region p pp)
(downcase-region pp np)
(if (< arg 0)
(c-backward-subword)
(goto-char np))))
(if (< arg 0) (goto-char start))))
(defun c-downcase-subword (arg)
"Do the same as `downcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `downcase-word'."
(interactive "p")
(let ((start (point)))
(downcase-region (point) (c-forward-subword arg))
(if (< arg 0) (goto-char start))))
(defun c-upcase-subword (arg)
"Do the same as `upcase-word' but on subwords.
See the command `c-subword-mode' for a description of subwords.
Optional argument ARG is the same as for `upcase-word'."
(interactive "p")
(let ((start (point)))
(upcase-region (point) (c-forward-subword arg))
(if (< arg 0) (goto-char start))))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-02 20:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-02 20:46 c-subword-mode - inconsistent behavior Paul Curry
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.