emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Begging for show-paren change???


From: Stefan Monnier
Subject: Re: Begging for show-paren change???
Date: Sun, 13 Nov 2005 17:39:40 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> The example uses negative numbers to prevent impact to existing code.
> Some positive number range will work, as will (symbolp (cdr (syntax-after
> beg))).  I've tried all these ways with success.  Anything is fine for me.
> I'd like to be able to finally release these modes in working condition
> with 22.1.

I think we don't need to assume these things are numbers or anything.
We can just check (eq (cdr (syntax-after (1- end))) (cdr (syntax-after
beg))) which will work for negative integers, symbols, positive ints, ...

After all, the two chars are related by the fact that forward-sexp jumps
from one to the other, so it's extremely unlikely that the above check would
ever return a wrong answer (i.e. say that the two chars are correctly
matched when they are not).  For such an error to occur we'd need a syntax
where char CHAR1 has syntax "(a" and the other CHAR2 has ")a" and that they
do not match.  I.e. "a" is expected to both close CHAR1 and to open CHAR2
(so the syntax of "a" needs to be sometimes "(" and sometimes ")") and CHAR2
does not close CHAR1.  Can't think of any scenario where this
could occur.

So I just suggest the patch below instead.


        Stefan


--- paren.el    20 aoĆ» 2005 19:26:11 -0400      1.64
+++ paren.el    13 nov 2005 17:37:23 -0500      
@@ -181,7 +181,12 @@
                                       (cdr (syntax-after beg)))
                                   (eq (char-after beg)
                                       ;; This can give nil.
-                                      (cdr (syntax-after (1- end)))))))))))))
+                                      (cdr (syntax-after (1- end))))
+                                   ;; The cdr might hold a new paren-class
+                                   ;; info rather than a matching-char info,
+                                   ;; in which case the two CDRs should match.
+                                   (eq (cdr (syntax-after (1- end)))
+                                       (cdr (syntax-after beg))))))))))))
        ;;
        ;; Highlight the other end of the sexp, or unhighlight if none.
        (if (not pos)

--- simple.el   12 Nov 2005 00:10:56 -0000      1.762
+++ simple.el   13 Nov 2005 22:38:39 -0000
@@ -4314,9 +4314,8 @@
                          (eq (syntax-class syntax) 4)
                          (cdr syntax)))))
        (cond
-        ((or (null matching-paren)
-             (/= (char-before oldpos)
-                 matching-paren))
+        ((not (or (eq matching-paren (char-before oldpos))
+                 (eq matching-paren (cdr (syntax-after oldpos)))))
          (message "Mismatched parentheses"))
         ((not blinkpos)
          (if (not blink-matching-paren-distance)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]