unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
Cc: AMackenzie@harmanbecker.com, emacs-devel@gnu.org, rudalics@gmx.at
Subject: Re: AW: font-locking and open parens in column 0
Date: Sun, 12 Nov 2006 00:14:52 -0500	[thread overview]
Message-ID: <E1Gj7gC-0000mI-PG@fencepost.gnu.org> (raw)
In-Reply-To: <jwv64dmy5p0.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Fri, 10 Nov 2006 23:52:50 -0500)


    4 - the original motivation for the patch (i.e. point 1 above) is better
	addressed by not using beginning-of-defun and rely on syntax-ppss's
	cache instead.

The specific purpose of the change in beginning-of-defun-raw was simply to make
it correctly handle the case of open-paren-in-column-0-is-defun-start = nil
when there is no beginning-of-defun-function.

I know this discussion is part of a larger one, but I no longer
remember the rest of the issues in the larger discussion.

However, I did not realize that CC mode actually used that case.  I
thought it had a beginning-of-defun-function.  I was surprised just
now to see that it didn't have one.  Perhaps that should be changed.

However, taking out the use of syntax-ppss in beginning-of-defun-raw
isn't the right way to get good behavior in CC mode.  That would only
make it parse from the start of the file every time.

    3 - changing beginning-of-defun to use parse-partial-sexp (or worse
	syntax-ppss) defeats the purpose of using it as a syntax-begin-function.
	It may even break such uses (e.g. in emacs-lisp-mode).

Why would it break them?

(In any case, such a problem won't arise in Emacs Lisp mode, since
open-paren-in-column-0-is-defun-start = t.)

    I think the problem is that beginning-of-defun has many different possible
    uses, not all of which are compatible:

    1 - it can be used as a "move to toplevel" (i.e. outside of any syntactic
	element).  Currently it's a not reliable way to do that, but it's been
	used as a good heuristic.  Note that in some languages such a concept
	may not even be very meaningful: in languages whose files are commonly
	composed of only one toplevel element (typically a module or a class
	which then contains other elements inside themselves maybe classes or
	modules, ...).

    2 - it can be used as a form of "backward-paragraph-for-prog-langs", to move
	to the beginning of a "block of text".  In case where defuns can be
	nested, this first only move to the beginning of the nested defun.

Normally I'd expect it NOT to treat nested definitions as defuns.
Normally they would be entirely indented.

    3 - a mix of the two: define some level of nesting (if any) as the main one
       (typically either the toplevel one, or if the toplevel is a single
       element, use the next level down) and move to the beginning of the defun
       at that level.

You can get this behavior by adjusting the indentation
when open-paren-in-column-0-is-defun-start = t.

    A reliable way to get behavior 1 is to use syntax-ppss rather than
    beginning-of-defun.

That is a good point.  Maybe some uses of beginning-of-defun
(such as in Font Lock) ought to use syntax-ppss instead.

I think that is orthogonal to the question of this change
in beginning-of-defun-raw.

    The proposed patch basically tries to make beginning-of-defun follow the
    behavior number 1 and to make it do so reliably.

I don't see it that way.

    OTOH it might be a good idea indeed to change beginning-of-defun so that it
    ignores regexp-matches if they're inside comments or strings.  But that'd be
    a different patch, which would apply regardless of
    open-paren-in-column-0-is-defun-start.

I agree, that might be good.

  parent reply	other threads:[~2006-11-12  5:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-03  8:44 AW: font-locking and open parens in column 0 Mackenzie, Alan
2006-11-03 14:02 ` martin rudalics
2006-11-03 14:14 ` Stefan Monnier
2006-11-04  6:38 ` AW: " Richard Stallman
2006-11-10 17:49   ` Stefan Monnier
2006-11-11  2:11     ` Richard Stallman
2006-11-11  4:52       ` Stefan Monnier
2006-11-12  5:14         ` Richard Stallman
2006-11-12  5:14         ` Richard Stallman [this message]
2006-11-12 19:45           ` martin rudalics
2006-11-13 17:16           ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Gj7gC-0000mI-PG@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=AMackenzie@harmanbecker.com \
    --cc=emacs-devel@gnu.org \
    --cc=rudalics@gmx.at \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).