unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: emacs-devel@gnu.org
Subject: Re: font-lock-syntactic-keywords obsolet?
Date: Sat, 18 Jun 2016 17:12:49 +0000	[thread overview]
Message-ID: <20160618171249.GA5796@acm.fritz.box> (raw)
In-Reply-To: <CAM-tV-_2gsfR-d7vAB4tZK-=oPXUFfU3=o_Md48XG+MK68DtFw@mail.gmail.com>

Hello, Noam.

On Sat, Jun 18, 2016 at 11:07:03AM -0400, Noam Postavsky wrote:
> On Sat, Jun 18, 2016 at 3:03 AM, Andreas Röhler
> <andreas.roehler@online.de> wrote:
> > Anyone who looks how syntax-propertize-function is introduced in source,
> > --given some decent understanding of Emacs Lisp-- will see the bunch of
> > issues. There is nothing to explain here.

> Ah, is this like The Emperor's New Clothes? Anyone who doesn't see the
> issues lacks a decent understand of Emacs Lisp? I'll play the kid who
> doesn't know any better. Here's the source where
> syntax-propertize-function is introduced:

I see the issues here, and I avoid syntax-propertize and syntax-ppss
wherever possible.

> ;;; Applying syntax-table properties where needed.

> (defvar syntax-propertize-function nil
>   ;; Rather than a -functions hook, this is a -function because it's easier
>   ;; to do a single scan than several scans: with multiple scans,
> [more commentary explaining issues with multiple scans that have been
> avoided...]

> Looks like a normal defvar to me.

Let's have that excerpt in full:

  ;; Rather than a -functions hook, this is a -function because it's easier
  ;; to do a single scan than several scans: with multiple scans, one cannot
  ;; assume that the text before point has been propertized, so syntax-ppss
  ;; gives unreliable results (and stores them in its cache to boot, so we'd
  ;; have to flush that cache between each function, and we couldn't use
  ;; syntax-ppss-flush-cache since that would not only flush the cache but also
  ;; reset syntax-propertize--done which should not be done in this case).

The issue is not caused by multiple scans.  CC Mode (in particular C++
Mode) does several scans to apply syntax-table text properties, simply
because that's a natural thing to do (there being several distinct
reasons for these properties being applied).  That way, it's easier to
debug, easier to understand, and less error prone.

It is not "easier to do a single scan".  It is simply that a single scan
is virtually forced if one uses the syntax-ppss/syntax-propertize
mechanism, because:
(i) parse-partial-sexp is very likely to be needed for calculating the
  syntax-table text properties.  Because only some s-t properties will
  have been applied, precise control of p-p-s is needed.  I think users
  of syntax-ppss hold that using parse-partial-sexp directly is a Bad
  Thing.
(ii) The only way syntax-propertize gets called is by calling
  syntax-ppss for some position below where one needs the properties
  applying.

Additionally, syntax-ppss hasn't conformed with its specification w.r.t.
narrowed buffers for a long time, if ever.  (See bug #22983.)

Additionally 2, when syntax-propertize-function is non-nil, all
syntax-table text properties beyond point are wiped out by a change,
causing the need to regenerate them.  This is not always necessary, and
might be expensive in run time (see, again, C++ Mode).

In summary, the syntax-ppss/syntax-propertize mechanism might be a good
choice for implementing syntax-table text properties, but it is not
necessarily so.

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2016-06-18 17:12 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 10:18 font-lock-syntactic-keywords obsolet? Andreas Röhler
2016-06-17 22:13 ` Stefan Monnier
2016-06-18  7:03   ` Andreas Röhler
2016-06-18 15:07     ` Noam Postavsky
2016-06-18 17:12       ` Alan Mackenzie [this message]
2016-06-18 18:13         ` Stefan Monnier
2016-06-18 19:41           ` Noam Postavsky
2016-06-19  7:12             ` Andreas Röhler
2016-06-19 13:21               ` Noam Postavsky
2016-06-19 14:03                 ` Andreas Röhler
2016-06-19 14:36               ` Stefan Monnier
2016-06-19 15:12                 ` Alan Mackenzie
2016-06-19 15:18                   ` Dmitry Gutov
2016-06-19 15:26                     ` Alan Mackenzie
2016-06-19 15:52                       ` Stefan Monnier
2016-06-19 15:53                       ` Dmitry Gutov
2016-06-20  2:58                   ` Stefan Monnier
2016-06-20 11:57                     ` Alan Mackenzie
2016-06-20 13:37                       ` Stefan Monnier
2016-06-20 13:50                         ` Dmitry Gutov
2016-06-20 16:00                           ` Andreas Röhler
2016-06-20 18:15                             ` Dmitry Gutov
2016-06-20 23:33                               ` John Wiegley
2016-06-20 18:55                             ` Alan Mackenzie
2016-06-20 20:22                               ` Andreas Röhler
2016-06-19 15:27                 ` Andreas Röhler
2016-06-19 15:51                   ` Stefan Monnier
2016-06-19 12:31         ` Dmitry Gutov
2016-06-19 13:31           ` Alan Mackenzie
2016-06-19 13:48             ` Dmitry Gutov
2016-06-19 14:59               ` Alan Mackenzie
2016-06-19 15:07                 ` Dmitry Gutov
2016-06-19 15:18                   ` Alan Mackenzie
2016-06-19 15:22                     ` Dmitry Gutov
2016-06-19 15:34                       ` Alan Mackenzie
2016-06-19 15:50                         ` Dmitry Gutov
2016-06-19 17:15                           ` Alan Mackenzie
2016-06-19 17:55                             ` Dmitry Gutov
2016-06-19 22:20                               ` Dmitry Gutov
2016-06-20 10:22                               ` Alan Mackenzie
2016-06-20 11:50                                 ` Dmitry Gutov
2016-06-20 14:50                                   ` Alan Mackenzie
2016-06-20 15:02                                     ` Dmitry Gutov
2016-06-20 13:39                                 ` Stefan Monnier
2016-06-20 10:58                               ` Alan Mackenzie
2016-06-20 11:12                                 ` Andreas Röhler
2016-06-20 12:15                                 ` Dmitry Gutov
2016-06-20 14:52                                   ` Noam Postavsky
2016-06-20 15:57                                     ` Dmitry Gutov
2016-06-20 17:23                                       ` Noam Postavsky
2016-06-20 18:58                                         ` Dmitry Gutov
2016-06-20 15:25                                   ` Alan Mackenzie
2016-06-20 16:45                                     ` Dmitry Gutov
2016-06-20 18:12                                       ` Alan Mackenzie
2016-06-20 19:15                                         ` Dmitry Gutov
2016-06-20 20:08                                           ` Alan Mackenzie
2016-06-20 20:32                                             ` Dmitry Gutov
2016-06-21 14:40                                               ` Alan Mackenzie
2016-06-21 21:06                                                 ` Dmitry Gutov
2016-06-21 23:50                                                 ` Dmitry Gutov
2016-06-23 16:30                                                   ` Alan Mackenzie
2016-06-27 11:48                                                     ` Alan Mackenzie
2016-06-29  0:30                                                     ` Dmitry Gutov
2016-06-30  9:52                                                       ` Alan Mackenzie
2016-07-10  2:01                                                         ` Dmitry Gutov
2016-07-10 22:11                                                           ` Alan Mackenzie
2016-07-11  0:06                                                             ` Dmitry Gutov
2016-07-11 17:20                                                               ` Alan Mackenzie
2016-07-11 22:44                                                                 ` Dmitry Gutov
2016-06-20 22:45                                       ` John Wiegley
2016-06-20 23:30                                         ` Dmitry Gutov
2016-06-20 23:56                                           ` John Wiegley
2016-06-21  0:26                                           ` John Wiegley
2016-06-21 15:26                                           ` Alan Mackenzie
2016-06-21 16:09                                             ` Dmitry Gutov
2016-06-21 18:34                                               ` Andreas Röhler
2016-06-21 18:42                                                 ` John Wiegley
2016-06-21 18:52                                                   ` Eli Zaretskii
2016-06-27 11:50                                                     ` Andreas Röhler
2016-06-21 19:23                                                   ` Andreas Röhler
2016-06-21 18:49                                                 ` Eli Zaretskii
2016-06-21 21:05                                               ` Alan Mackenzie
2016-06-21 21:17                                                 ` Dmitry Gutov
2016-06-21 16:28                                             ` Dmitry Gutov
2016-06-20  0:06                             ` Stefan Monnier
2016-06-20 11:03                               ` Alan Mackenzie
2016-06-20 13:53                                 ` Stefan Monnier
2016-06-20  4:33                             ` Stefan Monnier
2016-06-20  5:05                               ` John Wiegley
2016-06-19 23:59                         ` Stefan Monnier
2016-06-20  3:14                       ` Stefan Monnier
2016-06-20  3:20                         ` Dmitry Gutov
2016-06-20  3:47                           ` Stefan Monnier
2016-06-20  6:40                 ` Andreas Röhler
2016-06-20  3:08             ` 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=20160618171249.GA5796@acm.fritz.box \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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).