From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Proposed patch: ignore show-paren-mode fails in comments Date: Tue, 08 Sep 2015 16:12:32 +0200 Message-ID: <87vbblrodr.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1441721779 9668 80.91.229.3 (8 Sep 2015 14:16:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Sep 2015 14:16:19 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 08 16:16:14 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 1ZZJgo-0002kb-CN for ged-emacs-devel@m.gmane.org; Tue, 08 Sep 2015 16:16:02 +0200 Original-Received: from localhost ([::1]:34660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZJgn-0000wu-Lf for ged-emacs-devel@m.gmane.org; Tue, 08 Sep 2015 10:16:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZJdE-0008Sa-HA for emacs-devel@gnu.org; Tue, 08 Sep 2015 10:12:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZJdA-00020U-EB for emacs-devel@gnu.org; Tue, 08 Sep 2015 10:12:20 -0400 Original-Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:34062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZJdA-000208-6f for emacs-devel@gnu.org; Tue, 08 Sep 2015 10:12:16 -0400 Original-Received: by wicfx3 with SMTP id fx3so121899874wic.1 for ; Tue, 08 Sep 2015 07:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=ywMbsmuP49hd9rpHz4MT5m+j8FqNd/9h4jldmPFGrLo=; b=IGPQN+dO95VA5/mWtoLrFTL44QEeW4MNcLVMt/Q7YYARSh46hvCkTsomJUbuFMwW/x FWk4wn6giXQ/QqyWUwfom4XWbFuZlI4VBXl5iNBO1p/lFIH+DhzF1Uf6fg0n64HqWxJ7 cx2D9X6rrgQVMTdVJMd3bplFd0dhUxHib/zIF0dXVM/F8bvolN50pIZC9JzrSxc+KjAP Udev0wVkGQ2ZEjkIkWDa24B+pL+OAu49dEUf2TaYIw6bzNYePwKHticKWR6gOQDExBrh 3sQzZY2v+/8MFJfQ5TGdEy+pErS7mznj1cyFrWTItmy1kw773uCnUtWejUbOJ4+ktygq PuzA== X-Received: by 10.194.189.236 with SMTP id gl12mr32243722wjc.151.1441721534385; Tue, 08 Sep 2015 07:12:14 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id cx3sm5074428wjc.27.2015.09.08.07.12.13 for (version=TLS1_2 cipher=AES128-SHA256 bits=128/128); Tue, 08 Sep 2015 07:12:13 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::233 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:189712 Archived-At: --=-=-= Content-Type: text/plain Hi all, I like to have `show-paren-mode' in my Lisp buffers. However, it will fail to match the parens in commented multi-line expressions like this one: ;; => ;; (0 ;; (1 ;; (2 ;; (3 (4 (5 (6 (7 (8 (9 ())))))))))) I attach a patch to ignore these failures. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-paren.el-show-paren-default-Ignore-fails-in-com.patch >From 91ba1c3dee055ac4617445b944f28af63408f90c Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Tue, 8 Sep 2015 16:04:06 +0200 Subject: [PATCH] lisp/paren.el (show-paren--default): Ignore fails in comments --- lisp/paren.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/paren.el b/lisp/paren.el index 30314c2..adf2849 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -210,7 +210,9 @@ Where HERE-BEG..HERE-END is expected to be near point.") ;; If found a "matching" paren, see if it is the right ;; kind of paren to match the one we started at. (if (not (integerp pos)) - (if mismatch (list here-beg here-end nil nil t)) + (if mismatch + (unless (nth 4 (syntax-ppss)) + (list here-beg here-end nil nil t))) (let ((beg (min pos outside)) (end (max pos outside))) (unless (eq (syntax-class (syntax-after beg)) 8) (setq mismatch -- 2.5.1 --=-=-= Content-Type: text/plain Interestingly, as I pasted the code into this `message-mode' buffer, `show-paren-mode' doesn't fail any more, since ";;" don't register as comments any more. Maybe `scan-sexps' could be modified to scan differently (i.e. ignoring comments) if the starting position is in a comment. This would be preferable to just ignoring the scan errors like the attached patch does. What do you think? Oleh --=-=-=--