unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: XKCD/541 compliance, anyone?
Date: Thu, 01 Jan 2015 23:07:59 -0500	[thread overview]
Message-ID: <jwvlhll96pc.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: 87387udvr8.fsf@wmi.amu.edu.pl

>> Beware: syntax-propertize-function might already be in use, in which
>> case you should probably use add-function to combine the two.
> Hm.  My Emacs (24.3) doesn't have anything called add-function.  I
> checked on the interwebs, and it seems it's part of the new advice
> system.  I'll have to upgrade finally.

Tho you probably only need this syntax-propertize-smileys thingy for
modes which don't use syntax-propertize-function yet, so maybe
add-function is not really necessary.

> My question: wouldn't it be reasonable to change
> syntax-propertize-function into a /list/ of functions?

At this point, it wouldn't be reasonable, no: add-function works as well
already.  Also, combining various functions there doesn't work quite as
easily as it sounds.  For example, in your case, it works OK to put your
function before the major mode's function, but doing it the other way
around wouldn't always work right.  For more general
syntax-propertize-functions, you can't just run them in turn.

> I checked it, and I see it's even better, it will make it buffer-local.
> Again: very handy.  BTW: do I guess correctly that the reason that
> parse-sexp-lookup-properties is nil by default (and the reason for its
> existence in the first place) is performance issues?  If yes, is the
> difference between having it nil and t substantial on modern hardware?

No, the difference is negligible.  It's a historical left-over.

>>> However, it did not work (in text mode); my make-smileys-punctuation
>>> seems not even to get called.
>> Right, syntax-propertization is done lazily, so if nothing calls
>> syntax-propertize, then that's that.  Usually the main triggers for
>> syntax-propertize are syntax-ppss and font-lock, but neither is likely
>> to be used in text-mode.  So you'll probably need to arrange for font-lock
>> to be enabled *and* for font-lock-keywords-only not to be set to t.
> Well, I did not understand everything you wrote here.  I guess I will
> just have to RTFM; I vaguely remember reading about "lazy font-lock" 15
> years ago,

This is unrelated.  I used "lazy" in the general sense of "do things
as late as possible".

>> Probably because font-lock-keywords-only is set to t, so font-lock
>> doesn't end up calling syntax-ppss.
> Yes it is, though I don't (yet) understand what this means.  See above.

This has to do with the way font-lock handles strings and comments
separately from other highlighting.  In message-mode, this special
strings-and-comments highlighting is disabled, yet, that's the one that
normally triggers syntax-propertize.

You could also use something like

   (defun my-call-syntax-propertize (limit)
     (syntax-propertize limit)
     (goto-char limit)
     nil)
   (font-lock-add-keywords nil '((my-call-syntax-propertize)))

> Thank you so much!

My pleasure,


        Stefan




  reply	other threads:[~2015-01-02  4:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 21:16 XKCD/541 compliance, anyone? Marcin Borkowski
2014-12-04 22:34 ` Stefan Monnier
2014-12-04 23:10   ` Marcin Borkowski
2014-12-05 22:33   ` Marcin Borkowski
2014-12-05 23:41     ` Artur Malabarba
2014-12-05 23:48       ` Marcin Borkowski
2014-12-31  9:19   ` Marcin Borkowski
2015-01-01 17:07     ` Stefan Monnier
2015-01-01 21:41       ` Marcin Borkowski
2015-01-02  4:07         ` Stefan Monnier [this message]
2015-01-02 10:09           ` Marcin Borkowski
2015-01-03  1:47             ` Stefan Monnier
2015-01-07 21:55               ` Marcin Borkowski
2015-01-02 14:39       ` Marcin Borkowski
2015-01-03  1:49         ` Stefan Monnier
2015-01-07 22:09       ` Marcin Borkowski
2015-01-07 22:37         ` Stefan Monnier
2015-01-08  1:09           ` Marcin Borkowski
2015-01-08  1:49             ` Stefan Monnier
2015-01-08  2:37               ` Marcin Borkowski
     [not found]               ` <mailman.17449.1420684651.1147.help-gnu-emacs@gnu.org>
2015-01-08  3:11                 ` Stefan Monnier
2015-01-08 14:10                   ` Marcin Borkowski
2015-03-15  1:40 ` Marcin Borkowski
2015-03-15 18:39   ` 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=jwvlhll96pc.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@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.
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).