emacs-devel
[Top][All Lists]
Advanced

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

Re: simplifying beginning-of-defun


From: Eric M. Ludlam
Subject: Re: simplifying beginning-of-defun
Date: Sun, 27 Sep 2009 22:04:48 -0400

On Sun, 2009-09-27 at 18:52 -0400, Stefan Monnier wrote:

> 
> > I think there are these variants:
> 
> > * A program wants the default behavior
> > * A major mode wants to change the interactive form
> > * A program wants use the major-mode behavior
> > * A third tool (ie - cedet) wants to change the interactive forms
> >   without breaking the above three, and without modifying the global map
> 
> I can't think of a reason why #3 wouldn't want to be affected by #4.
> Note that for #2, it's not just the interactive form, since it also
> affects #3 (e.g. mark-defun, send-defun-to-inferior-process, younameit,
> ...).

Hmmm.  A dilemma.  Given this C code:

int
main()
{
  return 0;
}

The original beginning-of-defun stops at the {.  (ie, if you unset
beginning-of-defun-function).

The c variant knows to stop at the i in int.
CEDET also knows to stop at the i in int.

In effect, cc-mode, and CEDET agree.  It doesn't matter who takes over
beginning-of-defun duty.

In this C++ example:


namespace foo {

  int myfcn() {
    return 1;
  }

}

If the cursor is on the "return", beginning-of-defun-raw gets completely
lost, cc-mode jumps to namespace, and CEDET jumps to the i in int.

For the range of interactive fcns you mentioned above, when used
interactively, the CEDET behavior is preferred.  Within cc-mode, it
likely needs to land on the namespace line because that is what it
historically has done.  The base behavior, of course, is not really
desirable.  Sure, a user could re-indent their code, but that is not
always an option.

Of course, perhaps I am wrong in thinking that stopping on 'int' is
preferred, but I do know it is preferred by me.  Would this make the
CEDET behavior as found in 'senator' completely new in some way?


> > I think of CEDET as being able to 'glitz' up functions like
> > beginning-of-defun by making them accurate.  Programs that actually want
> > to use CEDET to get the more accurate behavior will not use
> > 'beginning-of-defun' at all.
> 
> What about programs that want to use CEDET but that also want to work
> when CEDET is not available?  They would most likely want to use
> beginning-of-defun.

I had not contemplated this in the context of beginning-of-defun.
Ideally they would not need some if statement to deal with the issue.
Of course, the need here would be pretty basic stuff too if it was
robust to the actual landing place being different for different
situations, sort of the way narrow-to-defun might not care exactly where
it lands, so long as it goes somewhere.

Eric




reply via email to

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