[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: electric-pair-mode as a minor mode?
From: |
Stefan Monnier |
Subject: |
Re: electric-pair-mode as a minor mode? |
Date: |
Mon, 30 Mar 2015 09:53:15 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> (defun message--syntax-propertize (beg end)
> ;; first, remove all `syntax-table' properties
> (remove-text-properties beg end '(syntax-table nil))
This should not be necessary (it's done by syntax-propertize before it
calls syntax-propertize-function).
> ;; propertize smileys as "generic comments"
> ;;
> (goto-char beg)
> (while (search-forward-regexp ":-?[()]" end 'noerror)
> (add-text-properties (match-beginning 0) (match-end 0)
> '(syntax-table (14 . nil))))
14 is definitely not right. A "comment fence" means "this char starts
or ends a comment, depending on whether we're inside a comment".
So putting this on 3 consecutive chars tells Emacs that the first
2 chars make up a comment and the 3rd is the beginning of a comment
(which might extend til the end of the buffer).
> ;; idem for citations
> ;;
> (goto-char beg)
> (while (search-forward-regexp
> (concat "^" message-cite-prefix-regexp ".*")
> end 'noerror)
You might want to move the "concat" out of the loop ;-)
> (add-text-properties (match-beginning 0) (match-end 0)
> '(syntax-table (14 . nil)))))
> * I have no idea how "expensive" this naive approach is.
Shouldn't be much more expensive than doing the same thing in font-lock.
Not sure who's considered maintainer of message.el, but you should check
with Lars, see what he thinks of it.
> * Although the `syntax-table' property seems to be set correctly, and
> both show-paren mode and electric-pair-mode seem to dtrt, I saw many
> cases where M-: (nth 4 (syntax-ppss)) didn't return non-nil when it
> should have, and vice versa. Is this part of the
> `parse-sexp-lookup-properties' sematics, that `syntax-ppss' becomes
> meaningless?
That's because you mis-used the comment markers. They should only be
put at the beginning and at the end of the comment.
> * I'm using `message-cite-prefix-regexp' to detect citations. It's what
> font-lock in lisp/gnus/message.el uses so it seems ideal. But there
> are also a lot of vars like `message-yank-prefix', whose docstring
> contains the following line which baffles me:
>> Fix `message-cite-prefix-regexp' if it is set to an abnormal value.
Hopefully Lars can say something useful about that.
Stefan
- Re: electric-pair-mode as a minor mode?, (continued)
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/27
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/27
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/28
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/28
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/28
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/28
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/29
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/29
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/29
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/30
- Re: electric-pair-mode as a minor mode?,
Stefan Monnier <=
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/30
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/30
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/30
- Re: electric-pair-mode as a minor mode?, João Távora, 2015/03/30
- Re: electric-pair-mode as a minor mode?, Stefan Monnier, 2015/03/30
- Re: electric-pair-mode as a minor mode?, Yuri D'Elia, 2015/03/27
Re: electric-pair-mode as a minor mode?, Tom Willemse, 2015/03/27