all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Miles Bader <miles@gnu.org>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: movement bindings in c-mode
Date: Mon, 23 Jun 2008 14:13:34 +0000	[thread overview]
Message-ID: <20080623141334.GA7132@muc.de> (raw)
In-Reply-To: <buo7icgo8bw.fsf@dhapc248.dev.necel.com>

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	other threads:[~2008-06-23 14:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-23  8:37 movement bindings in c-mode Miles Bader
2008-06-23 14:13 ` Alan Mackenzie [this message]
2008-06-23 13:57   ` Miles Bader
2008-06-23 14:09   ` Miles Bader
2008-06-23 17:05     ` Alan Mackenzie
2008-06-23 18:36       ` David Hansen
2008-06-23 18:40         ` Lennart Borgman (gmail)
2008-06-27 21:50           ` Alan Mackenzie
2008-06-27 21:49         ` Alan Mackenzie
2008-06-23 18:45       ` Stefan Monnier
2008-06-24  2:32       ` Miles Bader
2008-06-27 21:41       ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080623141334.GA7132@muc.de \
    --to=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.