all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: joaotavora@gmail.com (João Távora)
Cc: Yuri D'Elia <wavexx@thregr.org>,
	Lars Magne Ingebrigtsen <larsi@gnus.org>,
	emacs-devel@gnu.org
Subject: Re: electric-pair-mode as a minor mode?
Date: Mon, 30 Mar 2015 09:53:15 -0400	[thread overview]
Message-ID: <jwv4mp2fvt0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jjb384mbtqh.fsf@gmail.com> ("João Távora"'s message of "Mon, 30 Mar 2015 11:46:24 +0100")

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



  reply	other threads:[~2015-03-30 13:53 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 19:51 electric-pair-mode as a minor mode? Yuri D'Elia
2015-03-27  2:18 ` Stefan Monnier
2015-03-27  8:04   ` Yuri D'Elia
2015-03-27 13:19     ` Stefan Monnier
2015-03-27 11:18   ` João Távora
2015-03-27 13:25     ` Stefan Monnier
2015-03-27 14:09       ` João Távora
2015-03-27 18:20         ` Stefan Monnier
2015-03-28 16:11           ` João Távora
2015-03-28 20:36             ` Stefan Monnier
2015-03-28 21:47               ` João Távora
2015-03-28 23:09                 ` João Távora
2015-03-29  4:01                 ` Stefan Monnier
2015-03-29 20:41                   ` João Távora
2015-03-30  0:54                     ` Stefan Monnier
2015-03-30 10:46                       ` João Távora
2015-03-30 13:53                         ` Stefan Monnier [this message]
2015-03-30 15:43                           ` João Távora
2015-03-30 20:33                             ` Stefan Monnier
2015-03-30 20:42                               ` João Távora
2015-03-30 21:47                                 ` João Távora
2015-03-30 22:02                                 ` Stefan Monnier
2015-04-11 16:06                                   ` João Távora
2015-04-12 11:56                                     ` Stefan Monnier
2015-04-12 13:16                                       ` João Távora
2015-04-12 16:39                                         ` Dmitry Gutov
2015-04-12 22:16                                           ` João Távora
2015-04-12 23:10                                             ` Dmitry Gutov
2015-04-15 21:32                                               ` João Távora
2015-04-15 13:59                                     ` Lars Magne Ingebrigtsen
2015-04-15 21:16                                       ` João Távora
2015-04-15 21:21                                         ` Lars Magne Ingebrigtsen
2015-04-15 21:39                                           ` João Távora
2015-04-15 21:43                                             ` Lars Magne Ingebrigtsen
2015-04-26 10:28                                               ` João Távora
2015-04-26 19:48                                                 ` Lars Magne Ingebrigtsen
2015-04-27  2:29                                                 ` Stefan Monnier
2015-03-27 19:38     ` Yuri D'Elia
2015-03-27 12:52   ` Tom Willemse
2015-03-27 19:01     ` Stefan Monnier
2015-03-28 15:47       ` bug#19528: " João Távora
2015-03-28 15:47       ` João Távora
2015-03-28 17:37         ` bug#19528: " Glenn Morris
2015-03-28 21:01           ` João Távora
2015-04-14  6:28             ` Glenn Morris

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=jwv4mp2fvt0.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=larsi@gnus.org \
    --cc=wavexx@thregr.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.