[Top][All Lists]

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

c-beginning-of-defun. Bugfixes in CC Mode (@SourceForge) not yet in sava

From: Alan Mackenzie
Subject: c-beginning-of-defun. Bugfixes in CC Mode (@SourceForge) not yet in savannah [Was Mysterious fontification/C++ context issue]
Date: 15 Dec 2006 09:39:21 +0100
Date: Fri, 15 Dec 2006 09:49:59 +0000
User-agent: Mutt/1.5.9i

Hi, Richard.

I've separated this into a new thread.

On Fri, Dec 15, 2006 at 12:03:16AM -0500, Richard Stallman wrote:

[ .... ]

> A different but related question:

> Should C mode do (setq beginning-of-defun-function
> 'c-beginning-of-defun) Is there any reason that would be bad?

Yes.  C-M-a should be bound directly to c-beginning-of-defun (as it is
in the current address@hidden version).

Unfortunately, in beginning-of-defun, b-o-d-function doesn't get passed
the ARG, therefore needs to be called repeatedely in a loop from b-o-d.
This makes optimisation for large ARG impossible.

c-beginning-of-defun (the version in cc-mode.sourceforge) DOES optimise,
bringing a factor of 10 speed-up for large ARG: I measured the following
timings on my deceased 166 MHz box some while ago:  With a freshly
opened src/keyboard.c, do M->.  Then time C-u 100 C-M-a:

     Unoptimised version: 44 seconds.
     Optimised version: 4 seconds.

The optimisation consisted of doing the initial analysis of the starting
position (inside a function's brace block / inside its header / between
the end of the brace block and terminating semicolon / ....) only once
instead of once for each repetition.  The same for the final movement
from '{' to the start of the defun's header.  The main loop simply goes
back ARG brace blocks.

Also, c-beginning-of-defun calls b-o-d to help set up CC Mode's cache.
We'd have to be careful to avoid recursion.  Not difficult, but needs


There is a bug in the current savannah version of c-beginning-of-defun:
Put point between two defuns in a file.c.  Do M-- C-M-a.  It goes
forward too many defuns.  This has been fixed in the SourceForge

There are several bugs in CC Mode, mostly syntax analysis bugs, which
have been fixed at SourceForge, but I haven't yet transferred to
savannah.  Apologies - I was unable to hack for several months this
year, and the pretest announcement took me by surprise.  Do you want to
consider these for inclusion in Emacs 22?


reply via email to

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