[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
blink-matching-open does not work for text property parens
From: |
Martin Stjernholm |
Subject: |
blink-matching-open does not work for text property parens |
Date: |
Thu, 21 Aug 2003 22:50:07 +0200 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) Emacs/20.7 (gnu/linux) |
If a mode implements parens selectively on some characters using the
`syntax-table' text property (with parse-sexp-lookup-properties set to
non-nil) then the standard paren blinking function
`blink-matching-open' won't work correctly. The reason is that it uses
`char-syntax' and `matching-paren' on the character itself, without
regard to the properties it might have in the buffer. This patch fixes
that:
Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.617
diff -C3 -r1.617 simple.el
*** lisp/simple.el 17 Aug 2003 00:15:53 -0000 1.617
--- lisp/simple.el 21 Aug 2003 20:43:08 -0000
***************
*** 3500,3506 ****
(point)))))
(let* ((oldpos (point))
(blinkpos)
! (mismatch))
(save-excursion
(save-restriction
(if blink-matching-paren-distance
--- 3500,3507 ----
(point)))))
(let* ((oldpos (point))
(blinkpos)
! (mismatch)
! matching-paren)
(save-excursion
(save-restriction
(if blink-matching-paren-distance
***************
*** 3514,3525 ****
(setq blinkpos (scan-sexps oldpos -1)))
(error nil)))
(and blinkpos
! (/= (char-syntax (char-after blinkpos))
! ?\$)
! (setq mismatch
! (or (null (matching-paren (char-after blinkpos)))
(/= (char-after (1- oldpos))
! (matching-paren (char-after blinkpos))))))
(if mismatch (setq blinkpos nil))
(if blinkpos
;; Don't log messages about paren matching.
--- 3515,3534 ----
(setq blinkpos (scan-sexps oldpos -1)))
(error nil)))
(and blinkpos
! (save-excursion
! (goto-char blinkpos)
! (not (looking-at "\\s$")))
! (setq matching-paren
! (or (and parse-sexp-lookup-properties
! (let ((prop (get-text-property blinkpos
'syntax-table)))
! (and (consp prop)
! (eq (car prop) 4)
! (cdr prop))))
! (matching-paren (char-after blinkpos)))
! mismatch
! (or (null matching-paren)
(/= (char-after (1- oldpos))
! matching-paren))))
(if mismatch (setq blinkpos nil))
(if blinkpos
;; Don't log messages about paren matching.
2003-08-21 Martin Stjernholm <mast@lysator.liu.se>
* simple.el (blink-matching-open): Work correctly on chars that
are designated as parens through the syntax-table text property.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- blink-matching-open does not work for text property parens,
Martin Stjernholm <=