From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?iso-8859-1?Q?Jo=C3=A3o_T=C3=A1vora?=) Newsgroups: gmane.emacs.devel Subject: Re: electric-pair-mode as a minor mode? Date: Mon, 30 Mar 2015 11:46:24 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1427715532 25590 80.91.229.3 (30 Mar 2015 11:38:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 30 Mar 2015 11:38:52 +0000 (UTC) Cc: Yuri D'Elia , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 30 13:38:51 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 1YcY1i-0008A6-7W for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 13:38:42 +0200 Original-Received: from localhost ([::1]:33205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcY1h-00042R-Lq for ged-emacs-devel@m.gmane.org; Mon, 30 Mar 2015 07:38:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcY1d-00042M-Pf for emacs-devel@gnu.org; Mon, 30 Mar 2015 07:38:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YcY1a-0007c3-Jg for emacs-devel@gnu.org; Mon, 30 Mar 2015 07:38:37 -0400 Original-Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:34381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YcY1a-0007bz-DT for emacs-devel@gnu.org; Mon, 30 Mar 2015 07:38:34 -0400 Original-Received: by wgbdm7 with SMTP id dm7so64789498wgb.1 for ; Mon, 30 Mar 2015 04:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:references:message-id:mime-version :content-type:content-transfer-encoding; bh=cff7G1mCIXdocjMKQg1Fkn9tfx/WSgfezjCuLCfrZks=; b=JM5JkfLudWJzYTdcNEjE+SrKm3/+9widLuv4CJ+pcbwCxrU9xRhgr+vfs7It24RKX+ NIL+FcOjIfnIw3Ux59FkJ82bQ4EWsobuNg0XNrxUoBDOluyhrJdWzwCd/TeHxiIXF1Ct XED1d8L8k4yNIyhJ/ii/ZgYFDxQdTDBJVJIBCGDsngmclmMKbRe2XFQmVdtKCjxdmdWn 3x/YsE/LN08jUbugH00Pj3FogoODdni1nG9024ehh7AV1o9QFWJ6e8eWpTjMe35tyvgV CWa0WFG33GfrShDIzFDKDGdQSlLdxa/kelhW01Kr+9jnLMg5IVcFcfei8gbJqPaaOUkW +2Rg== X-Received: by 10.180.73.228 with SMTP id o4mr21918598wiv.74.1427715513804; Mon, 30 Mar 2015 04:38:33 -0700 (PDT) Original-Received: from GONDOMAR.yourcompany.com (53.236.108.93.rev.vodafone.pt. [93.108.236.53]) by mx.google.com with ESMTPSA id k1sm15373206wjn.9.2015.03.30.04.38.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Mar 2015 04:38:32 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22a 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:184542 Archived-At: Stefan Monnier writes: > I guess you'd d have to use syntax-propertize-function to catch&handle the > "unusual cases".=20 Here's my current attempt. (add-hook 'message-mode-hook 'joaot/setup-message-mode-syntax) =20=20=20=20=20 (defun joaot/setup-message-mode-syntax () (setq-local syntax-propertize-function 'message--syntax-propertize (setq-local parse-sexp-lookup-properties t) (setq-local parse-sexp-ignore-comments t)) =20=20=20=20=20 (defun message--syntax-propertize (beg end) ;; first, remove all `syntax-table' properties ;; (remove-text-properties beg end '(syntax-table nil)) ;; 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)))) ;; idem for citations ;; (goto-char beg) (while (search-forward-regexp (concat "^" message-cite-prefix-regexp ".*") end 'noerror) (add-text-properties (match-beginning 0) (match-end 0) '(syntax-table (14 . nil))))) It seems works well but: * I have no idea how "expensive" this naive approach is. * 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? =20=20 * 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. Can you have a look and give it some testing? Jo=E3o