+2013-12-13 Dmitry Gutov <dgutov@yandex.ru>
+
+ * simple.el (blink-matching--overlay): New variable.
+ (blink-matching-open): Instead of moving point, highlight the
+ matching paren with an overlay
+ (http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00333.html).
+
+ * faces.el (paren-showing-faces, show-paren-match)
+ (show-paren-mismatch): Move from paren.el.
+
2013-12-13 Leo Liu <sdl.web@gmail.com>
* indent.el (indent-region): Disable progress reporter in
"Face for displaying the currently selected item in TTY menus."
:group 'basic-faces)
+(defgroup paren-showing-faces nil
+ "Faces used to highlight paren matches."
+ :group 'paren-showing
+ :group 'faces
+ :version "22.1")
+
+(defface show-paren-match
+ '((((class color) (background light))
+ :background "turquoise") ; looks OK on tty (becomes cyan)
+ (((class color) (background dark))
+ :background "steelblue3") ; looks OK on tty (becomes blue)
+ (((background dark))
+ :background "grey50")
+ (t
+ :background "gray"))
+ "Face used for a matching paren."
+ :group 'paren-showing-faces)
+
+(defface show-paren-mismatch
+ '((((class color)) (:foreground "white" :background "purple"))
+ (t (:inverse-video t)))
+ "Face used for a mismatching paren."
+ :group 'paren-showing-faces)
+
\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Manipulating font names.
:group 'paren-showing
:version "20.3")
-(defgroup paren-showing-faces nil
- "Group for faces of Show Paren mode."
- :group 'paren-showing
- :group 'faces
- :version "22.1")
-
-(defface show-paren-match
- '((((class color) (background light))
- :background "turquoise") ; looks OK on tty (becomes cyan)
- (((class color) (background dark))
- :background "steelblue3") ; looks OK on tty (becomes blue)
- (((background dark))
- :background "grey50")
- (t
- :background "gray"))
- "Show Paren mode face used for a matching paren."
- :group 'paren-showing-faces)
(define-obsolete-face-alias 'show-paren-match-face 'show-paren-match "22.1")
-(defface show-paren-mismatch
- '((((class color)) (:foreground "white" :background "purple"))
- (t (:inverse-video t)))
- "Show Paren mode face used for a mismatching paren."
- :group 'paren-showing-faces)
(define-obsolete-face-alias 'show-paren-mismatch-face
'show-paren-mismatch "22.1")
START can be nil, if it was not found.
The function should return non-nil if the two tokens do not match.")
+(defvar blink-matching--overlay
+ (let ((ol (make-overlay (point) (point) nil t)))
+ (overlay-put ol 'face 'show-paren-match)
+ (delete-overlay ol)
+ ol)
+ "Overlay used to highlight the matching paren.")
+
(defun blink-matching-open ()
- "Move cursor momentarily to the beginning of the sexp before point."
+ "Momentarily highlight the beginning of the sexp before point."
(interactive)
(when (and (not (bobp))
blink-matching-paren)
(message "No matching parenthesis found"))))
((not blinkpos) nil)
((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.
+ ;; Matching open within window, temporarily highlight char
+ ;; after blinkpos but only if `blink-matching-paren-on-screen'
+ ;; is non-nil.
(and blink-matching-paren-on-screen
(not show-paren-mode)
- (save-excursion
- (goto-char blinkpos)
- (sit-for blink-matching-delay))))
+ (unwind-protect
+ (progn
+ (move-overlay blink-matching--overlay blinkpos (1+ blinkpos)
+ (current-buffer))
+ (sit-for blink-matching-delay))
+ (delete-overlay blink-matching--overlay))))
(t
(save-excursion
(goto-char blinkpos)