GNU bug report logs - #9461
24.0.50; Weird behaviour in "show-paren-mode"

Previous Next

Package: emacs;

Reported by: Dani Moncayo <dmoncayo <at> gmail.com>

Date: Wed, 7 Sep 2011 17:26:01 UTC

Severity: normal

Found in version 24.0.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

Full log


Message #35 received at 9461 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9461 <at> debbugs.gnu.org, Dani Moncayo <dmoncayo <at> gmail.com>
Subject: Re: bug#9461: 24.0.50; Weird behaviour in "show-parent-mode"
Date: Fri, 09 Sep 2011 12:54:21 +0300
>> Perhaps nothing should be highlighted when syntax of the previous
>> character is `escape' `\'.
>
> I think show-paren-mode should at least follow the same heuristic as the
> default blink-paren behavior, which indeed refrains from blinking the
> "open paren" when the close-paren is escaped.

I verified that the following patch provides this result:

=== modified file 'lisp/paren.el'
--- lisp/paren.el	2011-01-25 04:08:28 +0000
+++ lisp/paren.el	2011-09-09 09:46:03 +0000
@@ -135,13 +135,23 @@ (define-minor-mode show-paren-mode
 ;; and show it until input arrives.
 (defun show-paren-function ()
   (if show-paren-mode
-      (let ((oldpos (point))
+      (let* ((oldpos (point))
 	    (dir (cond ((eq (syntax-class (syntax-after (1- (point)))) 5) -1)
                        ((eq (syntax-class (syntax-after (point)))      4) 1)))
+	     (unescaped
+	      (when dir
+		;; Verify an even number of quoting characters precede the paren.
+		;; Follow the same logic as in `blink-matching-open'.
+		(= (if (= dir -1) 1 0)
+		   (logand 1 (- (point)
+				(save-excursion
+				  (if (= dir -1) (forward-char -1))
+				  (skip-syntax-backward "/\\")
+				  (point)))))))
 	    pos mismatch face)
 	;;
 	;; Find the other end of the sexp.
-	(when dir
+	(when unescaped
 	  (save-excursion
 	    (save-restriction
 	      ;; Determine the range within which to look for a match.

BTW, I don't understand one comment about escaped parens in `show-paren-function':

	      ;; Move back the other way and verify we get back to the
	      ;; starting point.  If not, these two parens don't really match.
	      ;; Maybe the one at point is escaped and doesn't really count.

It seems irrelevant to the current problem.




This bug report was last modified 13 years and 314 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.