aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-04 00:16:50 +0000
committerRichard M. Stallman1997-07-04 00:16:50 +0000
commit12eb8433586f4c8d5ffd572283e1f495ae130d6f (patch)
tree6dfc2cb995d692f363a1c3643ac9dac0440f7a04
parentf9be457422ea2d87f40142731d9a98701b82bf42 (diff)
downloademacs-12eb8433586f4c8d5ffd572283e1f495ae130d6f.tar.gz
emacs-12eb8433586f4c8d5ffd572283e1f495ae130d6f.zip
(show-paren-idle-timer): New defvar.
(show-paren-mode): Add :initialize attr in the defcustom. Test the value at end of file, and turn on the mode if true.
-rw-r--r--lisp/paren.el65
1 files changed, 32 insertions, 33 deletions
diff --git a/lisp/paren.el b/lisp/paren.el
index 893407b96c1..859049d6183 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -40,39 +40,6 @@
40;; This is the overlay used to highlight the closeparen right before point. 40;; This is the overlay used to highlight the closeparen right before point.
41(defvar show-paren-overlay-1 nil) 41(defvar show-paren-overlay-1 nil)
42 42
43(defvar show-paren-idle-timer nil)
44
45(defvar show-paren-mode) ;; Real definition comes later.
46
47;;;###autoload
48(defun show-paren-mode (&optional arg)
49 "Toggle Show Paren mode.
50With prefix ARG, turn Show Paren mode on if and only if ARG is positive.
51Returns the new status of Show Paren mode (non-nil means on).
52
53When Show Paren mode is enabled, any matching parenthesis is highlighted
54in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
55 (interactive "P")
56 (when window-system
57 (let ((on-p (if arg
58 (> (prefix-numeric-value arg) 0)
59 (not show-paren-mode))))
60 (setq blink-matching-paren-on-screen (not on-p))
61 (when show-paren-idle-timer
62 (cancel-timer show-paren-idle-timer))
63 (if on-p
64 (setq show-paren-idle-timer (run-with-idle-timer
65 show-paren-delay t
66 'show-paren-function))
67 (and show-paren-overlay (overlay-buffer show-paren-overlay)
68 (delete-overlay show-paren-overlay))
69 (and show-paren-overlay-1 (overlay-buffer show-paren-overlay-1)
70 (delete-overlay show-paren-overlay-1)))
71 (setq show-paren-mode on-p))))
72
73;; Naughty hack. This variable was originally a `defvar' to keep track of
74;; whether Show Paren mode was turned on or not. As a `defcustom' with
75;; special `:set' and `:require' forms, we can provide custom mode control.
76(defcustom show-paren-mode nil 43(defcustom show-paren-mode nil
77 "Toggle Show Paren mode. 44 "Toggle Show Paren mode.
78When Show Paren mode is enabled, any matching parenthesis is highlighted 45When Show Paren mode is enabled, any matching parenthesis is highlighted
@@ -80,6 +47,7 @@ after `show-paren-delay' seconds of Emacs idle time.
80You must modify via \\[customize] for this variable to have an effect." 47You must modify via \\[customize] for this variable to have an effect."
81 :set (lambda (symbol value) 48 :set (lambda (symbol value)
82 (show-paren-mode (or value 0))) 49 (show-paren-mode (or value 0)))
50 :initialize 'custom-initialize-default
83 :type 'boolean 51 :type 'boolean
84 :group 'paren-showing 52 :group 'paren-showing
85 :require 'paren) 53 :require 'paren)
@@ -114,6 +82,34 @@ otherwise)."
114 :group 'faces 82 :group 'faces
115 :group 'paren-showing) 83 :group 'paren-showing)
116 84
85(defvar show-paren-idle-timer nil)
86
87;;;###autoload
88(defun show-paren-mode (&optional arg)
89 "Toggle Show Paren mode.
90With prefix ARG, turn Show Paren mode on if and only if ARG is positive.
91Returns the new status of Show Paren mode (non-nil means on).
92
93When Show Paren mode is enabled, any matching parenthesis is highlighted
94in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
95 (interactive "P")
96 (when window-system
97 (let ((on-p (if arg
98 (> (prefix-numeric-value arg) 0)
99 (not show-paren-mode))))
100 (setq blink-matching-paren-on-screen (not on-p))
101 (when show-paren-idle-timer
102 (cancel-timer show-paren-idle-timer))
103 (if on-p
104 (setq show-paren-idle-timer (run-with-idle-timer
105 show-paren-delay t
106 'show-paren-function))
107 (and show-paren-overlay (overlay-buffer show-paren-overlay)
108 (delete-overlay show-paren-overlay))
109 (and show-paren-overlay-1 (overlay-buffer show-paren-overlay-1)
110 (delete-overlay show-paren-overlay-1)))
111 (setq show-paren-mode on-p))))
112
117;; Find the place to show, if there is one, 113;; Find the place to show, if there is one,
118;; and show it until input arrives. 114;; and show it until input arrives.
119(defun show-paren-function () 115(defun show-paren-function ()
@@ -212,4 +208,7 @@ otherwise)."
212 208
213(provide 'paren) 209(provide 'paren)
214 210
211(if show-paren-mode
212 (show-paren-mode t))
213
215;;; paren.el ends here 214;;; paren.el ends here