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: Wed, 31 Dec 2014 10:19:04 +0100

On 2014-12-04, at 23:34, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> I have a dream: to have the s-exp functions ignore closing parens,
>> brackets etc. /after/, say, things matching
>
>> [;:B]-?
>
> You can use syntax-propertize-function to change the syntax class of
> those parens.

OK, so I did try.  This is what I came up with:

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

(defun enable-smileys-punctuation ()
  (setq syntax-propertize-function #'make-smileys-punctuation)
  (setq parse-sexp-lookup-properties t))

(add-hook 'text-mode-hook #'enable-smileys-punctuation)

However, it did not work (in text mode); my make-smileys-punctuation
seems not even to get called.  Curiously enough, it seems to work in
e.g. Elisp mode - but then again, not in message mode, for instance.

What might be going on here?

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