From: "Eric M. Ludlam" <eric@siege-engine.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org, Andreas Roehler <andreas.roehler@online.de>,
XEmacs-Beta@xemacs.org
Subject: Re: simplifying beginning-of-defun
Date: Sun, 27 Sep 2009 16:07:21 -0400 [thread overview]
Message-ID: <1254082041.6168.65.camel@projectile.siege-engine.com> (raw)
In-Reply-To: <jwvy6o0b58h.fsf-monnier+emacs@gnu.org>
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
next prev parent reply other threads:[~2009-09-27 20:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-26 17:52 simplifying beginning-of-defun Andreas Roehler
2009-09-26 21:44 ` Stefan Monnier
2009-09-27 8:10 ` Andreas Roehler
2009-09-27 18:40 ` Stefan Monnier
2009-09-28 6:50 ` Andreas Roehler
2009-09-28 22:46 ` Stefan Monnier
2009-09-29 6:53 ` Andreas Roehler
2009-09-29 8:29 ` Andreas Roehler
2009-09-27 10:26 ` Andreas Roehler
2009-09-27 11:17 ` Eric M. Ludlam
2009-09-27 18:53 ` Stefan Monnier
2009-09-27 20:07 ` Eric M. Ludlam [this message]
2009-09-27 22:52 ` Stefan Monnier
2009-09-28 2:04 ` Eric M. Ludlam
2009-09-28 4:06 ` Stefan Monnier
2009-09-28 11:20 ` Eric M. Ludlam
2009-09-29 6:50 ` Alan Mackenzie
2009-09-27 19:06 ` Glenn Morris
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=1254082041.6168.65.camel@projectile.siege-engine.com \
--to=eric@siege-engine.com \
--cc=XEmacs-Beta@xemacs.org \
--cc=andreas.roehler@online.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.