emacs-devel
[Top][All Lists]
Advanced

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

Re: movement bindings in c-mode


From: Alan Mackenzie
Subject: Re: movement bindings in c-mode
Date: Mon, 23 Jun 2008 14:13:34 +0000
User-agent: Mutt/1.5.9i

Hi, Miles!

On Mon, Jun 23, 2008 at 05:37:39PM +0900, Miles Bader wrote:
> In c-mode, I notice that C-M-a is bound to `c-beginning-of-defun',
> overriding the global binding to `beginning-of-defun'.

Yes.  This is deliberate.

> The generic `beginning-of-defun' function offers some additional
> functionality (in particular, it sets the mark before jumping), and
> seems to work just as well.

`beginning-of-defun' sets the mark?  This is something new, isn't it?  It
seems like a good idea, though.

> We should generally try to avoid gratuitous mode-specific rebinding of
> generic bindings that work properly.

I don't agree that `beginning-of-defun', in particular
`beginning-of-defun-function' works properly.

> I suppose this rebinding made sense in the past when the generic
> mechanism was less capable, but does it make sense any more?

The problem is that c-beginning-of-defun is S    L    O    W.  It spends
nearly all its time locating the pertinent top-level {, and then
grappling its way to the start of the defun header from there, including
the tortuous analysis of a possible (but usually absent) k&r parameter
block of unbounded length.  This latter is what caused such pain whilst
doing C-x 4 a in C files several weeks ago.  However, when given a repeat
count, it only needs to do this tortuous analysis once., rapidly zapping
back by sexps n-1 times.

b-o-d is currently incapable of passing the repeat count to
b-o-d-function, which means that the tortuous analysis would have to be
repeated n times for an argument of n, were this mechanism to be used by
CC Mode.

I did some timings some while ago (on my now deceased 166 MHz box) on
..../src/keyboard.c.  (c-beginning-of-defun 100) took 4 seconds.  Looping
(c-beginning-of-defun) 100 times took 44 seconds.

> Any comments?

I think beginning-of-defun-function should be passed the repeat count
(naturally doing the right thing when that function can't take it).  But
we've had this discussion several times before on this list without
reaching a consensus.

> [A similar argument applies to other commands like c-end-of-defun]

> Thanks,

> -Miles

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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