emacs-devel
[Top][All Lists]
Advanced

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

Re: Incompatibility of CC mode


From: Masatake YAMATO
Subject: Re: Incompatibility of CC mode
Date: Mon, 09 Apr 2007 22:20:18 +0900 (JST)

Hi,

I'm the author of cc-subword.

> 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.

Thank you.

About downcase and upcase, what you say and your code are correct.
So I installed your code to emacs's CVS repository.
Soon cc-mode maintainer will also install it to cc-mode's CVS repository.

    2007-04-09  Paul Curry <address@hidden>  (tiny change)

            * progmodes/cc-subword.el (c-downcase-subword, c-upcase-subword): 
            Don't move point if ARG is netagive.


About capitalize, I've written my own code based on your code; and 
installed it.

First of all, in subword, I cannot find expected behavior of capitalize,
which all of people can agree with. As you wrote my old is wrong because
point moves with netagive argument. This is obvious. However, I wonder
which character should be upcase when a netagive argument is given.

I'd like to explain why I modify your code here:

Consider doing "-3 M-c" at xxx.
                             ^ point is here.

[With your original code]      efg bceFghi xxx => Efg BceFghi Xxx
[With my modified code]        efg bceFghi xxx => efg BceFghi Xxx
[With real capitalize-word]    efg bce Fghi xxx => efg Bce Fghi Xxx

I think my modified code is rather similar to the real `capitalize-word'
than your original code. If you have strong objection, please, tell me.

    2007-04-09  Masatake YAMATO  <address@hidden>

            * 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.


    (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))
            (advance (if (< arg 0) nil t)))
        (dotimes (i count)
          (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)))
            (upcase-region p pp)
            (downcase-region pp np)
            (goto-char (if advance np p))))
        (unless advance
          (goto-char start))))



Regards,
Masatake YAMATO




reply via email to

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