From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: electric-pair-mode as a minor mode? Date: Mon, 30 Mar 2015 09:53:15 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1427723624 2889 80.91.229.3 (30 Mar 2015 13:53:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Mar 2015 13:53:44 +0000 (UTC) Cc: Yuri D'Elia , Lars Magne Ingebrigtsen , emacs-devel@gnu.org To: joaotavora@gmail.com (=?windows-1252?B?Sm/jbyBU4XZvcmE=?=) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 30 15:53:30 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yca85-0005Tm-Ey for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 15:53:25 +0200 Original-Received: from localhost ([::1]:34038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yca84-0005Zw-VP for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 09:53:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yca80-0005YS-Vm for emacs-devel@gnu.org; Mon, 30 Mar 2015 09:53:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yca7x-00039O-7O for emacs-devel@gnu.org; Mon, 30 Mar 2015 09:53:20 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:7267) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yca7x-00039I-41 for emacs-devel@gnu.org; Mon, 30 Mar 2015 09:53:17 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXYBBVYjEAs0EhQYDapIjAMnOg+DPgODcASoOw X-IPAS-Result: AgUFAGvvdVRBbthL/2dsb2JhbAA3gVOhb4EIgXYBBVYjEAs0EhQYDapIjAMnOg+DPgODcASoOw X-IronPort-AV: E=Sophos;i="5.01,1,1400040000"; d="scan'208";a="114946782" Original-Received: from 65-110-216-75.cpe.pppoe.ca (HELO pastel.home) ([65.110.216.75]) by ironport2-out.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Mar 2015 09:53:16 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id F1D59E57; Mon, 30 Mar 2015 09:53:15 -0400 (EDT) In-Reply-To: (=?windows-1252?B?Ikpvw6NvIFTD?= =?windows-1252?B?oXZvcmEiJ3M=?= message of "Mon, 30 Mar 2015 11:46:24 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:184544 Archived-At: > (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