emacs-devel
[Top][All Lists]
Advanced

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

Not appropriate message for mismatched parens


From: Herbert Euler
Subject: Not appropriate message for mismatched parens
Date: Wed, 25 Apr 2007 19:01:23 +0800

The variable `blink-matching-paren-distance' limits searching region
for blinking matching parens.  However, the error message for the case
in which the distance between the opening paren and the closing paren
is larger than `blink-matching-paren-distance' is not so very
appropriate.  It says "Mismatched parenthesis", just the same as for
the normal cases.

This may be not the truth in some cases.  The truth is possibly the
parens _are matched_, but the distance between them exceeds the value
of `blink-matching-paren-distance'.  In such a case, saying
"Mismatched parenthesis" could confuse the user.

I wrote a patch, please check it:

*** simple.el~  Wed Apr 25 18:25:55 2007
--- simple.el   Wed Apr 25 18:56:34 2007
*************** (defun blink-matching-open ()
*** 4483,4491 ****
           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))
--- 4483,4496 ----
           blinkpos
           message-log-max  ; Don't log messages about paren matching.
           matching-paren
!          open-paren-line-string
!          open-paren-may-be-outside)
        (save-excursion
        (save-restriction
+         (setq open-paren-may-be-outside
+               (and blink-matching-paren-distance
+                    (< (minibuffer-prompt-end)
+                       (- (point) blink-matching-paren-distance))))
          (if blink-matching-paren-distance
              (narrow-to-region (max (minibuffer-prompt-end)
                                     (- (point) blink-matching-paren-distance))
*************** (defun blink-matching-open ()
*** 4510,4519 ****
                     ;; 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.
--- 4515,4530 ----
                     ;; a matching-char info, in which case the two CDRs
                     ;; should match.
                     (eq matching-paren (cdr (syntax-after (1- oldpos))))))
!         (if open-paren-may-be-outside
!             (message (concat "Open parenthesis is not found in the region "
!                              "restricted by `blink-matching-paren-distance'"))
!           (message "Mismatched parentheses")))
         ((not blinkpos)
          (if (not blink-matching-paren-distance)
!             (message "Unmatched parenthesis")
!           (if open-paren-may-be-outside
!               (message (concat "Open parenthesis is not found in the region "
!                                "restricted by `blink-matching-parent-distance'")))))
         ((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.

Regards,
Guanpeng Xu


Connect to the next generation of MSN Messenger  Get it now!
reply via email to

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