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: Fri, 02 Jan 2015 15:39:36 +0100

On 2015-01-01, at 18:07, Stefan Monnier <address@hidden> wrote:

>> (defvar smiley-regex "[:;x>B][,']?-?[]()PD]"
>>   "This regex should match smileys.")
>
>> (defun make-smileys-punctuation (beg end)
>>   "Look for smileys between BEG and END position in the buffer, and
>>   change their syntax property to punctuation."
>>   (goto-char beg)
>>   (while (re-search-forward smiley-regex end t)
>>     (put-text-property (match-beginning 0) (match-end 0) 'syntax-table 
>> '(1))))
>
> You can also use
>
>    (syntax-propertize-rules (smiley-regex (0 ".")))

OK, so I started reading about this.

I can see that syntax-propertize-rules is a huuuge macro I'm afraid even
to look at from distance;-).  Do I get it correctly that it "outputs" a
function, so that I can write

(setq syntax-propertize-function (syntax-propertize-rules (...)))

?

>> (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.

Yes, I know that; I wanted just to experiment a bit to start with.

> 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.

I have global font lock mode, so font locking is on everywhere.

>> 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.

Now that is strange: it seems that font-lock-keywords-only is set to t
in mu4e-message mode (where I'm now), but grepping through mu4e sources
didn't give any results (nor did isearching message.el).  I'll have to
look into this further (check other modes etc.)

>         Stefan

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

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