emacs-devel
[Top][All Lists]
Advanced

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

Re: address@hidden: parentheses matching failure on valid sexp]


From: martin rudalics
Subject: Re: address@hidden: parentheses matching failure on valid sexp]
Date: Thu, 13 Sep 2007 11:22:52 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> It looks right.  Please install.

It was too simplistic.  In fact I have to distinguish two cases when
`blink-matching-paren-distance' is non-nil:

- `point-min' is at most `blink-matching-paren-distance' characters
  before `point'.  If in this case I don't find a matching paren there
  cannot be any such paren and I should treat this case just as with
  `blink-matching-paren-distance' nil.

- `point-min' is more than `blink-matching-paren-distance' characters
  before `point'.  If I don't find a matching paren now there could
  still be one before the start of the narrowed region.  In this case
  I'd have to display a different message (or maybe no message at all).

See the attached patch.
*** simple.el.~1.859.2.8.~      Sun Aug 26 22:26:46 2007
--- simple.el   Thu Sep 13 10:58:10 2007
***************
*** 4483,4495 ****
           blinkpos
           message-log-max  ; Don't log messages about paren matching.
           matching-paren
!          open-paren-line-string)
        (save-excursion
        (save-restriction
!         (if blink-matching-paren-distance
!             (narrow-to-region (max (minibuffer-prompt-end)
!                                    (- (point) blink-matching-paren-distance))
!                               oldpos))
          (condition-case ()
              (let ((parse-sexp-ignore-comments
                     (and parse-sexp-ignore-comments
--- 4483,4499 ----
           blinkpos
           message-log-max  ; Don't log messages about paren matching.
           matching-paren
!          open-paren-line-string
!          old-start
!          new-start)
        (save-excursion
        (save-restriction
!         (when blink-matching-paren-distance
!           (setq old-start (minibuffer-prompt-end))
!           (setq new-start
!                 (max old-start (- (point) blink-matching-paren-distance)))
!           (when (> new-start old-start)
!             (narrow-to-region new-start oldpos)))
          (condition-case ()
              (let ((parse-sexp-ignore-comments
                     (and parse-sexp-ignore-comments
***************
*** 4505,4519 ****
                          (eq (syntax-class syntax) 4)
                          (cdr syntax)))))
        (cond
         ((not (or (eq matching-paren (char-before oldpos))
!                    ;; The cdr might hold a new paren-class info rather than
!                    ;; a matching-char info, in which case the two CDRs
!                    ;; should match.
!                    (eq matching-paren (cdr (syntax-after (1- oldpos))))))
          (message "Mismatched parentheses"))
-        ((not blinkpos)
-         (if (not blink-matching-paren-distance)
-             (message "Unmatched parenthesis")))
         ((pos-visible-in-window-p blinkpos)
          ;; Matching open within window, temporarily move to blinkpos but only
          ;; if `blink-matching-paren-on-screen' is non-nil.
--- 4509,4526 ----
                          (eq (syntax-class syntax) 4)
                          (cdr syntax)))))
        (cond
+        ((not blinkpos)
+         (if (and blink-matching-paren-distance (> new-start old-start))
+             ;; When `blink-matching-paren-distance' is non-nil and we
+             ;; narrowed the buffer display more suitable message.
+             (message "No matching parenthesis found")
+           (message "Unmatched parenthesis")))
         ((not (or (eq matching-paren (char-before oldpos))
!                  ;; The cdr might hold a new paren-class info rather than
!                  ;; a matching-char info, in which case the two CDRs
!                  ;; should match.
!                  (eq matching-paren (cdr (syntax-after (1- oldpos))))))
          (message "Mismatched parentheses"))
         ((pos-visible-in-window-p blinkpos)
          ;; Matching open within window, temporarily move to blinkpos but only
          ;; if `blink-matching-paren-on-screen' is non-nil.

reply via email to

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