Mercurial > emacs
comparison lisp/paren.el @ 3917:00ea0fc45685
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 29 Jun 1993 18:21:12 +0000 |
parents | d0f9cd48e8f6 |
children | bbac27613cee |
comparison
equal
deleted
inserted
replaced
3916:b3f0b10b39c8 | 3917:00ea0fc45685 |
---|---|
22 ;; Load this and it will display highlighting on whatever | 22 ;; Load this and it will display highlighting on whatever |
23 ;; paren matches the one before or after point. | 23 ;; paren matches the one before or after point. |
24 | 24 |
25 ;;; Code: | 25 ;;; Code: |
26 | 26 |
27 (defvar blink-paren-overlay nil) | 27 (defvar show-paren-overlay nil) |
28 | 28 |
29 ;; Find the place to blink, if there is one, | 29 ;; Find the place to show, if there is one, |
30 ;; and blink it until input arrives. | 30 ;; and show it until input arrives. |
31 (defun blink-paren-command-hook () | 31 (defun show-paren-command-hook () |
32 (let (pos dir mismatch (oldpos (point)) | 32 (let (pos dir mismatch (oldpos (point)) |
33 (face (if (face-equal 'highlight 'region) | 33 (face (if (face-equal 'highlight 'region) |
34 'underline 'highlight))) | 34 'underline 'highlight))) |
35 (cond ((eq (char-syntax (following-char)) ?\() | 35 (cond ((eq (char-syntax (following-char)) ?\() |
36 (setq dir 1)) | 36 (setq dir 1)) |
57 (/= (char-after (1- end)) | 57 (/= (char-after (1- end)) |
58 (logand (lsh (aref (syntax-table) | 58 (logand (lsh (aref (syntax-table) |
59 (char-after beg)) | 59 (char-after beg)) |
60 -8) | 60 -8) |
61 255)))))) | 61 255)))))) |
62 ;; If they don't properly match, don't blink. | 62 ;; If they don't properly match, don't show. |
63 (if mismatch | 63 (if mismatch |
64 (setq pos nil)))) | 64 (setq pos nil)))) |
65 (cond (pos | 65 (cond (pos |
66 (if blink-paren-overlay | 66 (if show-paren-overlay |
67 (move-overlay blink-paren-overlay (- pos dir) pos) | 67 (move-overlay show-paren-overlay (- pos dir) pos) |
68 (setq blink-paren-overlay | 68 (setq show-paren-overlay |
69 (make-overlay (- pos dir) pos))) | 69 (make-overlay (- pos dir) pos))) |
70 (overlay-put blink-paren-overlay 'face face) | 70 (overlay-put show-paren-overlay 'face face) |
71 ;;; This is code to blink the highlighting. | 71 ;;; This is code to blink the highlighting. |
72 ;;; It is desirable to avoid this because | 72 ;;; It is desirable to avoid this because |
73 ;;; it would interfere with auto-save and gc when idle. | 73 ;;; it would interfere with auto-save and gc when idle. |
74 ;;; (while (sit-for 1) | 74 ;;; (while (sit-for 1) |
75 ;;; (overlay-put blink-paren-overlay | 75 ;;; (overlay-put show-paren-overlay |
76 ;;; 'face | 76 ;;; 'face |
77 ;;; (if (overlay-get blink-paren-overlay | 77 ;;; (if (overlay-get show-paren-overlay |
78 ;;; 'face) | 78 ;;; 'face) |
79 ;;; nil face))) | 79 ;;; nil face))) |
80 ) | 80 ) |
81 (t | 81 (t |
82 (delete-overlay blink-paren-overlay))))) | 82 (and show-paren-overlay (overlay-buffer show-paren-overlay) |
83 (delete-overlay show-paren-overlay)))))) | |
83 | 84 |
84 (add-hook 'post-command-hook 'blink-paren-command-hook) | 85 (add-hook 'post-command-hook 'show-paren-command-hook) |
85 | 86 |