help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XKCD/541 compliance, anyone?


From: Marcin Borkowski
Subject: Re: XKCD/541 compliance, anyone?
Date: Thu, 01 Jan 2015 22:41:15 +0100

On 2015-01-01, at 18:07, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> You can also use
>
>    (syntax-propertize-rules (smiley-regex (0 ".")))

Thanks, I didn't know about this function.  Very handy.

>> (defun enable-smileys-punctuation ()
>>   (setq syntax-propertize-function #'make-smileys-punctuation)
>
> 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.

My question: wouldn't it be reasonable to change
syntax-propertize-function into a /list/ of functions?  Right now the
manual says that it should be set up by major mode to achieve some
special effects.  In my case, however, it would be more appropriate to
use a minor mode (possibly even a global minor mode).  Wouldn't
syntax-propertize-functions be more appropriate here?

OTOH, one your answer on Emacs.SE says explicitly that the trend is to
go away from "<foo>-functions" and use "<foo>-function" instead.  What
is the rationale?  Do I guess correctly that it will be easier to
/remove/ things added this way?

>>   (setq parse-sexp-lookup-properties t))
>
> This is not necessary, it will be set by the syntax-propertize function.

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?

>> 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, when I was reading (almost) the whole Emacs manual.  I guess
this is something similar.  I'll write back to the list if I don't get
it from the manual.

>> but then again, not in message mode, for instance.
>
> 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.

>         Stefan

PS. I guess that I will have to turn the knowledge from this exchange to
a lengthy blog post.  As I said in some other thread: I've been using
Emacs for about 15 years now (which is not much by Emacs standards, but
/a lot/ by so-called /modern/ standards), and still learning /a lot/...

Thank you so much!

-- 
Marcin Borkowski               This email was proudly sent
http://mbork.pl                from my Emacs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]