all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs@gnu.org
Subject: Re: XKCD/541 compliance, anyone?
Date: Fri, 02 Jan 2015 15:39:36 +0100	[thread overview]
Message-ID: <87ppaxmel3.fsf@wmi.amu.edu.pl> (raw)
In-Reply-To: <jwv387ua1g5.fsf-monnier+gmane.emacs.help@gnu.org>


On 2015-01-01, at 18:07, Stefan Monnier <monnier@iro.umontreal.ca> 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



  parent reply	other threads:[~2015-01-02 14:39 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
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 [this message]
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

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

  git send-email \
    --in-reply-to=87ppaxmel3.fsf@wmi.amu.edu.pl \
    --to=mbork@wmi.amu.edu.pl \
    --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.
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.