[Top][All Lists]
[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 16:07:21 -0400 |
On Sun, 2009-09-27 at 14:53 -0400, Stefan Monnier wrote:
> > I agree with the basic mechanics of what Andreas is providing here, not
> > any specific feature change involved in the patch. If there were some
> > function like the -raw functions he proposed that program modes would
> > use if they wanted exactly that behavior, and a separate interactive
> > function, then that opens the door for improvements on the interactive
> > function.
>
> We already have beginning-of-defun and beginning-of-defun-raw exactly
> for these kinds of reasons.
Ok. I didn't research before responding. ;)
I just now grepped around, and no programs use beginning-of-defun-raw,
but they do use beginning-of-defun, and some use
MODE-beginning-of-defun.
> > This comes up specifically with CEDET, where I can use parser
> > information to do a real `beginning-of-defun' for langauges whos defuns
> > don't happen to start with a ( in the first column. From an interactive
> > point of view, a total win.
>
> So you mean you'd want both beginning-of-defun-raw-function and
> beginning-of-defun-function (additionally to (define-key map [remap
> beginning-of-defun] ...), of course)?
> I'd have to think about it.
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
> > From a programs point of view, this would mean disaster if all their
> > code was expecting the cursor to show up on some opening {, and not on
> > the text actually starting the defun. For modes like cc-mode that
> > write their own correct `beginning-of-defun', they would use that
> > internally anyway, so no loss.
>
> So you mean we should provide a default-beginning-of-defun which is not
> subject to any *-function fiddling and change some of the calls to
> beginning-of-defun to use that function instead, so they're more robust
> in cases where something like CEDET sets beginning-of-defun-function?
> That makes sense, yet.
That is one solution, though I'm not sure about the
beginning-of-defun-function setting, as the major mode may expect the
function to be set as done in the major-mode.
> > Right now, the feature I describe in CEDET/Semantic is done with advice
> > and various if statements making sure not to do the modification in
> > non-interactive cases. The code is in senator.el.
>
> I think that interactive/noninteractive is not the right distinction
> (there are non-interactive cases which would also benefit from using an
> improved implementation). It's probably the best (conservative)
> solution you could use, because the right solution requires more changes
> to other packages.
Exactly.
By way of example, the `set-mark' function has doc that specifically
says not to use it in programs, and suggests some other function to use.
Thus, someone could add advice to `set-mark' or `set-mark-command' to
add some glitz, but programs remain safe from the change.
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. They would instead get the current tag at
point, from which the location of the start/end of the tag is readily
available, along with a bunch of other info. Tweaking
beginning-of-defun is only useful as a way of giving the user a better
experience.
Other packages that use beginning-of-defun as a function currently work
as is, so we don't want to change the behavior for those uses. If those
packages want the new behavior, there are plenty of APIs in
CEDET/Semantic to do what they want at their leisure.
Eric
- Re: simplifying beginning-of-defun, (continued)
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/26
- Re: simplifying beginning-of-defun, Andreas Roehler, 2009/09/27
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/27
- Re: simplifying beginning-of-defun, Andreas Roehler, 2009/09/28
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/28
- Re: simplifying beginning-of-defun, Andreas Roehler, 2009/09/29
- Re: simplifying beginning-of-defun, Andreas Roehler, 2009/09/29
Re: simplifying beginning-of-defun, Andreas Roehler, 2009/09/27
- Re: simplifying beginning-of-defun, Eric M. Ludlam, 2009/09/27
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/27
- Re: simplifying beginning-of-defun,
Eric M. Ludlam <=
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/27
- Re: simplifying beginning-of-defun, Eric M. Ludlam, 2009/09/27
- Re: simplifying beginning-of-defun, Stefan Monnier, 2009/09/28
- Re: simplifying beginning-of-defun, Eric M. Ludlam, 2009/09/28
Re: simplifying beginning-of-defun, Alan Mackenzie, 2009/09/29
Re: simplifying beginning-of-defun, Glenn Morris, 2009/09/27