From 50d434d19883a12e50f736d8216e8e36566d2424 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Fri, 14 Mar 2014 20:01:39 +0200 Subject: [PATCH] Support the old `blink-matching-paren' behavior * lisp/simple.el (blink-matching-paren): Describe the new value, `jump', enabling the old behavior. (blink-matching-open): Use that value. Fixes: debbugs:17008 --- etc/NEWS | 5 +++++ lisp/ChangeLog | 6 ++++++ lisp/simple.el | 26 +++++++++++++++++--------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 04796bf37e2..3d69fe90b20 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -423,6 +423,11 @@ macros in registers. This searches the region for identical lines, and removes all but one copy of each repeated line. The lines need not be sorted. +--- +** `blink-matching-paren' now only highlights the matching open-paren +by default, instead of moving cursor. Set this variable to `jump' to +enable the old behavior. + * Changes in Specialized Modes and Packages in Emacs 24.4 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e1d98e3f18a..769b77809bc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-03-14 Dmitry Gutov + + * simple.el (blink-matching-paren): Describe the new value, + `jump', enabling the old behavior. + (blink-matching-open): Use that value. (Bug#17008) + 2014-03-14 Glenn Morris * finder.el (finder-no-scan-regexp): Add leim-list. diff --git a/lisp/simple.el b/lisp/simple.el index 881a633f972..d84708217b4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6341,8 +6341,12 @@ If called from Lisp, enable the mode if ARG is omitted or nil." :group 'paren-matching) (defcustom blink-matching-paren t - "Non-nil means show matching open-paren when close-paren is inserted." - :type 'boolean + "Non-nil means show matching open-paren when close-paren is inserted. +If t, highlight the paren. If `jump', move cursor to its position." + :type '(choice + (const :tag "Disable" nil) + (const :tag "Highlight" t) + (const :tag "Move cursor" jump)) :group 'paren-blinking) (defcustom blink-matching-paren-on-screen t @@ -6452,17 +6456,21 @@ The function should return non-nil if the two tokens do not match.") (message "No matching parenthesis found")))) ((not blinkpos) nil) ((pos-visible-in-window-p blinkpos) - ;; Matching open within window, temporarily highlight char - ;; after blinkpos but only if `blink-matching-paren-on-screen' + ;; Matching open within window, temporarily move to or 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) - (unwind-protect - (progn - (move-overlay blink-matching--overlay blinkpos (1+ blinkpos) - (current-buffer)) + (if (eq blink-matching-paren 'jump) + (save-excursion + (goto-char blinkpos) (sit-for blink-matching-delay)) - (delete-overlay blink-matching--overlay)))) + (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) -- 2.39.2