diff options
| author | Dmitry Gutov | 2013-12-13 06:14:17 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2013-12-13 06:14:17 +0200 |
| commit | 84c73ba09921f0918d98a5f5784d35d2db9a7577 (patch) | |
| tree | 58dafc4161cfc80b6ed662320a3f1618ccbbf679 | |
| parent | 11dde529083c0b3df2e8e91913426ed4975b77c3 (diff) | |
| download | emacs-84c73ba09921f0918d98a5f5784d35d2db9a7577.tar.gz emacs-84c73ba09921f0918d98a5f5784d35d2db9a7577.zip | |
Make blink-matching-paren perform blinking without moving the cursor
* lisp/faces.el (paren-showing-faces, show-paren-match)
(show-paren-mismatch): Move from paren.el.
* lisp/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).
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/faces.el | 24 | ||||
| -rw-r--r-- | lisp/paren.el | 22 | ||||
| -rw-r--r-- | lisp/simple.el | 23 |
4 files changed, 51 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5a0718bc3de..7b0e00d0251 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-12-13 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * simple.el (blink-matching--overlay): New variable. | ||
| 4 | (blink-matching-open): Instead of moving point, highlight the | ||
| 5 | matching paren with an overlay | ||
| 6 | (http://lists.gnu.org/archive/html/emacs-devel/2013-12/msg00333.html). | ||
| 7 | |||
| 8 | * faces.el (paren-showing-faces, show-paren-match) | ||
| 9 | (show-paren-mismatch): Move from paren.el. | ||
| 10 | |||
| 1 | 2013-12-13 Leo Liu <sdl.web@gmail.com> | 11 | 2013-12-13 Leo Liu <sdl.web@gmail.com> |
| 2 | 12 | ||
| 3 | * indent.el (indent-region): Disable progress reporter in | 13 | * indent.el (indent-region): Disable progress reporter in |
diff --git a/lisp/faces.el b/lisp/faces.el index 0e965a89ba7..3797056b167 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -2573,6 +2573,30 @@ It is used for characters of no fonts too." | |||
| 2573 | "Face for displaying the currently selected item in TTY menus." | 2573 | "Face for displaying the currently selected item in TTY menus." |
| 2574 | :group 'basic-faces) | 2574 | :group 'basic-faces) |
| 2575 | 2575 | ||
| 2576 | (defgroup paren-showing-faces nil | ||
| 2577 | "Faces used to highlight paren matches." | ||
| 2578 | :group 'paren-showing | ||
| 2579 | :group 'faces | ||
| 2580 | :version "22.1") | ||
| 2581 | |||
| 2582 | (defface show-paren-match | ||
| 2583 | '((((class color) (background light)) | ||
| 2584 | :background "turquoise") ; looks OK on tty (becomes cyan) | ||
| 2585 | (((class color) (background dark)) | ||
| 2586 | :background "steelblue3") ; looks OK on tty (becomes blue) | ||
| 2587 | (((background dark)) | ||
| 2588 | :background "grey50") | ||
| 2589 | (t | ||
| 2590 | :background "gray")) | ||
| 2591 | "Face used for a matching paren." | ||
| 2592 | :group 'paren-showing-faces) | ||
| 2593 | |||
| 2594 | (defface show-paren-mismatch | ||
| 2595 | '((((class color)) (:foreground "white" :background "purple")) | ||
| 2596 | (t (:inverse-video t))) | ||
| 2597 | "Face used for a mismatching paren." | ||
| 2598 | :group 'paren-showing-faces) | ||
| 2599 | |||
| 2576 | 2600 | ||
| 2577 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2601 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2578 | ;;; Manipulating font names. | 2602 | ;;; Manipulating font names. |
diff --git a/lisp/paren.el b/lisp/paren.el index 6f386573b01..5db5878ccf5 100644 --- a/lisp/paren.el +++ b/lisp/paren.el | |||
| @@ -72,30 +72,8 @@ active, you must toggle the mode off and on again for this to take effect." | |||
| 72 | :group 'paren-showing | 72 | :group 'paren-showing |
| 73 | :version "20.3") | 73 | :version "20.3") |
| 74 | 74 | ||
| 75 | (defgroup paren-showing-faces nil | ||
| 76 | "Group for faces of Show Paren mode." | ||
| 77 | :group 'paren-showing | ||
| 78 | :group 'faces | ||
| 79 | :version "22.1") | ||
| 80 | |||
| 81 | (defface show-paren-match | ||
| 82 | '((((class color) (background light)) | ||
| 83 | :background "turquoise") ; looks OK on tty (becomes cyan) | ||
| 84 | (((class color) (background dark)) | ||
| 85 | :background "steelblue3") ; looks OK on tty (becomes blue) | ||
| 86 | (((background dark)) | ||
| 87 | :background "grey50") | ||
| 88 | (t | ||
| 89 | :background "gray")) | ||
| 90 | "Show Paren mode face used for a matching paren." | ||
| 91 | :group 'paren-showing-faces) | ||
| 92 | (define-obsolete-face-alias 'show-paren-match-face 'show-paren-match "22.1") | 75 | (define-obsolete-face-alias 'show-paren-match-face 'show-paren-match "22.1") |
| 93 | 76 | ||
| 94 | (defface show-paren-mismatch | ||
| 95 | '((((class color)) (:foreground "white" :background "purple")) | ||
| 96 | (t (:inverse-video t))) | ||
| 97 | "Show Paren mode face used for a mismatching paren." | ||
| 98 | :group 'paren-showing-faces) | ||
| 99 | (define-obsolete-face-alias 'show-paren-mismatch-face | 77 | (define-obsolete-face-alias 'show-paren-mismatch-face |
| 100 | 'show-paren-mismatch "22.1") | 78 | 'show-paren-mismatch "22.1") |
| 101 | 79 | ||
diff --git a/lisp/simple.el b/lisp/simple.el index 4c6c836b700..78fb12f8c9c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -6308,8 +6308,15 @@ position just before the opening token and END is the position right after. | |||
| 6308 | START can be nil, if it was not found. | 6308 | START can be nil, if it was not found. |
| 6309 | The function should return non-nil if the two tokens do not match.") | 6309 | The function should return non-nil if the two tokens do not match.") |
| 6310 | 6310 | ||
| 6311 | (defvar blink-matching--overlay | ||
| 6312 | (let ((ol (make-overlay (point) (point) nil t))) | ||
| 6313 | (overlay-put ol 'face 'show-paren-match) | ||
| 6314 | (delete-overlay ol) | ||
| 6315 | ol) | ||
| 6316 | "Overlay used to highlight the matching paren.") | ||
| 6317 | |||
| 6311 | (defun blink-matching-open () | 6318 | (defun blink-matching-open () |
| 6312 | "Move cursor momentarily to the beginning of the sexp before point." | 6319 | "Momentarily highlight the beginning of the sexp before point." |
| 6313 | (interactive) | 6320 | (interactive) |
| 6314 | (when (and (not (bobp)) | 6321 | (when (and (not (bobp)) |
| 6315 | blink-matching-paren) | 6322 | blink-matching-paren) |
| @@ -6351,13 +6358,17 @@ The function should return non-nil if the two tokens do not match.") | |||
| 6351 | (message "No matching parenthesis found")))) | 6358 | (message "No matching parenthesis found")))) |
| 6352 | ((not blinkpos) nil) | 6359 | ((not blinkpos) nil) |
| 6353 | ((pos-visible-in-window-p blinkpos) | 6360 | ((pos-visible-in-window-p blinkpos) |
| 6354 | ;; Matching open within window, temporarily move to blinkpos but only | 6361 | ;; Matching open within window, temporarily highlight char |
| 6355 | ;; if `blink-matching-paren-on-screen' is non-nil. | 6362 | ;; after blinkpos but only if `blink-matching-paren-on-screen' |
| 6363 | ;; is non-nil. | ||
| 6356 | (and blink-matching-paren-on-screen | 6364 | (and blink-matching-paren-on-screen |
| 6357 | (not show-paren-mode) | 6365 | (not show-paren-mode) |
| 6358 | (save-excursion | 6366 | (unwind-protect |
| 6359 | (goto-char blinkpos) | 6367 | (progn |
| 6360 | (sit-for blink-matching-delay)))) | 6368 | (move-overlay blink-matching--overlay blinkpos (1+ blinkpos) |
| 6369 | (current-buffer)) | ||
| 6370 | (sit-for blink-matching-delay)) | ||
| 6371 | (delete-overlay blink-matching--overlay)))) | ||
| 6361 | (t | 6372 | (t |
| 6362 | (save-excursion | 6373 | (save-excursion |
| 6363 | (goto-char blinkpos) | 6374 | (goto-char blinkpos) |