[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A fix for show-paren-function problem
From: |
Richard . G . Bielawski |
Subject: |
A fix for show-paren-function problem |
Date: |
Tue, 30 Nov 2004 21:55:38 -0600 |
I believe the following patch to show-paren-function in paren.el
will fix a long standing bug that causes show-paren-mode to
incorrectly highlight matching parens as mismatched if their
syntax was assigned via font-lock-syntactic-keywords or put.
The patch does not change the current behavior in text where
syntax is determined by the syntax table alone. But it does
afford the programmer assigning syntax arbitrarily more
flexibility in determining what will be considered a match.
For example:
All these pairs should highlight as properly matched:
Begin End begin end BEGIN END begin end;
^ ^ ^ ^ ^ ^ ^ ^
While these are mismatched because `block' requires `end block'.
block end;
^ ^
Such conditions are easily handled by the fix below while
not changing purely syntax-table based matching in any way.
;; If found a "matching" paren, see if it is the right
;; kind of paren to match the one we started at.
(when (integerp pos)
(let ((beg (min pos oldpos)) (end (max pos oldpos)))
(when (/= (char-syntax (char-after beg)) ?\$)
(setq mismatch
- (not (eq (char-before end)
+ (not (eq (or (cdr (get-text-property (1- end) 'syntax-table))
+ (char-before end))
;; This can give nil.
- (matching-paren (char-after beg)))))))))))
+ (or (cdr (get-text-property beg 'syntax-table))
+ (matching-paren (char-after beg))))))))))))
Richard Bielawski
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A fix for show-paren-function problem,
Richard . G . Bielawski <=