all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
Cc: Alan Mackenzie <acm@muc.de>, Richard Stallman <rms@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: AW: font-locking and open parens in column 0
Date: Fri, 03 Nov 2006 15:02:33 +0100	[thread overview]
Message-ID: <454B4BF9.5090608@gmx.at> (raw)
In-Reply-To: <DA6197CAE190A847B662079EF7631C0603407A89@OEKAW2EXVS03.hbi.ad.harman.com>

Good afternoon, Alan

 >          1         2         3         4         5         6         7  3
 > I agree with you.  :-)  However, my patch is to do with
 > beginning-of-defun-raw, not font-locking.

My problem is with font-locking and I thought your patch wanted to
address that problem (as you also stated some lines below).

 > Are you saying that
 > open-paren-in-column-0-is-defun-start shouldn't exist at all?  When it is
 > nil, a paren in column 0 may not, of itself, be regarded as a defun
 > start.

I fail to understand the present state of things.  On the one hand,
`open-paren-in-column-0-is-defun-start' is customizable which means a
user should be able to set it and a major mode should respect that.  On
the other hand, c-mode deliberately sets this to nil.  I think users
should be free to express their choice here if they consider their
machine inapt for scanning from bob.

 > I would say, rather, that font-locking should not use b-o-defun-raw when
 > o-p-i-c-0-i-d-s is nil, except in exceptional circumstances.

Font-lock uses `syntax-ppss' which may call `syntax-begin-function'
which may be defined as `beginning-of-defun' which usually calls
`beginning-of-defun-raw'.  When I open a C file and jump to a position
before stealth fontification gets there, that's the way things behave.

 > The case
 > you spotted in syntax.c (and I've really no idea how you did ;-), is
 > such an exceptional case.

I spotted that incidentally when scrolling backwards through syntax.c.
Anyway, it *is* exceptional and thus should not warrant any major
change.  Richard's patch just comes in handy.

 > CC Mode caches parenthesis structures.

... which parallels the work of `syntax-ppss', hence we currently end up
with two caches for the same structures - I know c-mode has to work hard
to handle all sorts of older (X)Emacsen ...

 > My patch did fix the bug (a whole screenful of misfontified string in
 > syntax.c), though, didn't it?

It does fix it, and it's even pretty fast ;-).  But I still think the
"bug" is with the author who put the left paren in column zero of that
comment.  That author should be warned just as in emacs-lisp-mode.

 > You're talking about my patch to beginning-of-defun-raw, here, not the
 > stuff in CC Mode.  I don't have the source files to hand at the moment.
 >
 >
 >>(1) Consult `syntax-ppss' first.
 >>
 >>(2) Try to use the 9th field of the return value of
 >>`parse-partial-sexp'
 >>to find the outermost paren instead of up-/forward-/backward-listing.
 >>
 >>(3) Crowd the cache of `syntax-ppss' in order to avoid further scans.
 >
 >
 > OK, thanks!  I'll need to learn about these optimisations.
 > begining-of-defun-raw, when used in font locking, could be distressingly
 > slow without them.

Suggestion (1) obviously has nothing to do with font-locking (otherwise
we would end up with `syntax-ppss' calling `beginning-of-defun' calling
`syntax-ppss' ...) but with using `beginning-of-defun' interactively for
jumping to the beginning of the current function.  However, that's
something `c-beginning-of-defun' does perfectly for c-mode.

  reply	other threads:[~2006-11-03 14:02 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 [this message]
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
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

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

  git send-email \
    --in-reply-to=454B4BF9.5090608@gmx.at \
    --to=rudalics@gmx.at \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /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.