diff options
| author | Richard M. Stallman | 1993-07-10 05:16:08 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-10 05:16:08 +0000 |
| commit | 80e1673824eea9bfea34ebc8e7ca7b4cfdbf22d5 (patch) | |
| tree | c9f33be70e69809b6d13af0785544d6019122b14 | |
| parent | 757e603c903f9557c6bebbc9630127c5967d64f7 (diff) | |
| download | emacs-80e1673824eea9bfea34ebc8e7ca7b4cfdbf22d5.tar.gz emacs-80e1673824eea9bfea34ebc8e7ca7b4cfdbf22d5.zip | |
(show-paren-command-hook): Do nothing if not window-system.
| -rw-r--r-- | lisp/paren.el | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/lisp/paren.el b/lisp/paren.el index f1e66567b0a..221c6aaf5d4 100644 --- a/lisp/paren.el +++ b/lisp/paren.el | |||
| @@ -33,61 +33,62 @@ | |||
| 33 | ;; Find the place to show, if there is one, | 33 | ;; Find the place to show, if there is one, |
| 34 | ;; and show it until input arrives. | 34 | ;; and show it until input arrives. |
| 35 | (defun show-paren-command-hook () | 35 | (defun show-paren-command-hook () |
| 36 | (let (pos dir mismatch (oldpos (point)) | 36 | (if window-system |
| 37 | (face (if (face-equal 'highlight 'region) | 37 | (let (pos dir mismatch (oldpos (point)) |
| 38 | 'underline 'highlight))) | 38 | (face (if (face-equal 'highlight 'region) |
| 39 | (cond ((eq (char-syntax (following-char)) ?\() | 39 | 'underline 'highlight))) |
| 40 | (setq dir 1)) | 40 | (cond ((eq (char-syntax (following-char)) ?\() |
| 41 | ((eq (char-syntax (preceding-char)) ?\)) | 41 | (setq dir 1)) |
| 42 | (setq dir -1))) | 42 | ((eq (char-syntax (preceding-char)) ?\)) |
| 43 | (save-excursion | 43 | (setq dir -1))) |
| 44 | (save-restriction | 44 | (save-excursion |
| 45 | ;; Determine the range within which to look for a match. | 45 | (save-restriction |
| 46 | (if blink-matching-paren-distance | 46 | ;; Determine the range within which to look for a match. |
| 47 | (narrow-to-region (max (point-min) | 47 | (if blink-matching-paren-distance |
| 48 | (- (point) blink-matching-paren-distance)) | 48 | (narrow-to-region (max (point-min) |
| 49 | (min (point-max) | 49 | (- (point) blink-matching-paren-distance)) |
| 50 | (+ (point) blink-matching-paren-distance)))) | 50 | (min (point-max) |
| 51 | ;; Scan across one sexp within that range. | 51 | (+ (point) blink-matching-paren-distance)))) |
| 52 | (condition-case () | 52 | ;; Scan across one sexp within that range. |
| 53 | (setq pos (scan-sexps (point) dir)) | 53 | (condition-case () |
| 54 | (error nil)) | 54 | (setq pos (scan-sexps (point) dir)) |
| 55 | ;; See if the "matching" paren is the right kind of paren | 55 | (error nil)) |
| 56 | ;; to match the one we started at. | 56 | ;; See if the "matching" paren is the right kind of paren |
| 57 | (if pos | 57 | ;; to match the one we started at. |
| 58 | (let ((beg (min pos oldpos)) (end (max pos oldpos))) | 58 | (if pos |
| 59 | (and (/= (char-syntax (char-after beg)) ?\$) | 59 | (let ((beg (min pos oldpos)) (end (max pos oldpos))) |
| 60 | (setq mismatch | 60 | (and (/= (char-syntax (char-after beg)) ?\$) |
| 61 | (/= (char-after (1- end)) | 61 | (setq mismatch |
| 62 | (logand (lsh (aref (syntax-table) | 62 | (/= (char-after (1- end)) |
| 63 | (char-after beg)) | 63 | (logand (lsh (aref (syntax-table) |
| 64 | -8) | 64 | (char-after beg)) |
| 65 | 255)))))) | 65 | -8) |
| 66 | ;; If they don't properly match, don't show. | 66 | 255)))))) |
| 67 | (if mismatch | 67 | ;; If they don't properly match, don't show. |
| 68 | (progn | 68 | (if mismatch |
| 69 | (message "Paren mismatch") | 69 | (progn |
| 70 | ;;; (setq pos nil) | 70 | (message "Paren mismatch") |
| 71 | )))) | 71 | ;;; (setq pos nil) |
| 72 | (cond (pos | 72 | )))) |
| 73 | (if show-paren-overlay | 73 | (cond (pos |
| 74 | (move-overlay show-paren-overlay (- pos dir) pos) | 74 | (if show-paren-overlay |
| 75 | (setq show-paren-overlay | 75 | (move-overlay show-paren-overlay (- pos dir) pos) |
| 76 | (make-overlay (- pos dir) pos))) | 76 | (setq show-paren-overlay |
| 77 | (overlay-put show-paren-overlay 'face face) | 77 | (make-overlay (- pos dir) pos))) |
| 78 | ;;; This is code to blink the highlighting. | 78 | (overlay-put show-paren-overlay 'face face) |
| 79 | ;;; It is desirable to avoid this because | 79 | ;;; This is code to blink the highlighting. |
| 80 | ;;; it would interfere with auto-save and gc when idle. | 80 | ;;; It is desirable to avoid this because |
| 81 | ;;; it would interfere with auto-save and gc when idle. | ||
| 81 | ;;; (while (sit-for 1) | 82 | ;;; (while (sit-for 1) |
| 82 | ;;; (overlay-put show-paren-overlay | 83 | ;;; (overlay-put show-paren-overlay |
| 83 | ;;; 'face | 84 | ;;; 'face |
| 84 | ;;; (if (overlay-get show-paren-overlay | 85 | ;;; (if (overlay-get show-paren-overlay |
| 85 | ;;; 'face) | 86 | ;;; 'face) |
| 86 | ;;; nil face))) | 87 | ;;; nil face))) |
| 87 | ) | 88 | ) |
| 88 | (t | 89 | (t |
| 89 | (and show-paren-overlay (overlay-buffer show-paren-overlay) | 90 | (and show-paren-overlay (overlay-buffer show-paren-overlay) |
| 90 | (delete-overlay show-paren-overlay)))))) | 91 | (delete-overlay show-paren-overlay))))))) |
| 91 | 92 | ||
| 92 | (add-hook 'post-command-hook 'show-paren-command-hook) | 93 | (add-hook 'post-command-hook 'show-paren-command-hook) |
| 93 | 94 | ||