emacs-devel
[Top][All Lists]
Advanced

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

Re: end-of-defun is fubsr.


From: Alan Mackenzie
Subject: Re: end-of-defun is fubsr.
Date: Fri, 13 Feb 2009 11:08:19 +0000
User-agent: Mutt/1.5.9i

Hi, Stefan,

On Thu, Feb 12, 2009 at 04:35:04PM -0500, Stefan Monnier wrote:
> BTW, as you may have noticed I rewrote end-of-defun.  It should fix the
> asymptotic complexity issue (it still calls BOD-function typically
> twice, tho).

It still suffers an off-by-1 error.  For example, load a C file and
execute the following to make sure that the keys are appropriately
bound:

    (define-key c-mode-base-map "\C-\M-a" 'beginning-of-defun)
    (define-key c-mode-base-map "\C-\M-e" 'end-of-defun)

Now go to just after the end of a defun:

void (foo)
{
   return ;
}
 ^
 |

Now do C-M-e.  Point dribbles a bit of WS forward.

#########################################################################

The problem here is that the generic end-of-defun-function moves to some
arbitrary point in the WS between defuns.  c-end-of-defun-function is
typical of EOD-functions in this respect.

If point also begins somewhere in the inter-defun WS, after calling
BOD-function and EOD-function, it will land back at an arbitrary place
in the same WS, which may be before, at, or after the starting point.

We cannot, in the general case, deduce whether we started within or
outwith a defun by this mechanism.
 
>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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