aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/paren.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/paren.el')
-rw-r--r--lisp/paren.el31
1 files changed, 5 insertions, 26 deletions
diff --git a/lisp/paren.el b/lisp/paren.el
index 8fdf9d8f258..1dec96ad43f 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -40,20 +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;;;###autoload
44(defcustom show-paren-mode nil
45 "*Toggle Show Paren mode.
46When Show Paren mode is enabled, any matching parenthesis is highlighted
47after `show-paren-delay' seconds of Emacs idle time.
48Setting this variable directly does not take effect;
49use either \\[customize] or the function `show-paren-mode'."
50 :set (lambda (symbol value)
51 (show-paren-mode (or value 0)))
52 :initialize 'custom-initialize-default
53 :type 'boolean
54 :group 'paren-showing
55 :require 'paren)
56
57(defcustom show-paren-style 'parenthesis 43(defcustom show-paren-style 'parenthesis
58 "*Style used when showing a matching paren. 44 "*Style used when showing a matching paren.
59Valid styles are `parenthesis' (meaning show the matching paren), 45Valid styles are `parenthesis' (meaning show the matching paren),
@@ -98,24 +84,20 @@ otherwise)."
98(defvar show-paren-idle-timer nil) 84(defvar show-paren-idle-timer nil)
99 85
100;;;###autoload 86;;;###autoload
101(defun show-paren-mode (&optional arg) 87(define-minor-mode show-paren-mode
102 "Toggle Show Paren mode. 88 "Toggle Show Paren mode.
103With prefix ARG, turn Show Paren mode on if and only if ARG is positive. 89With prefix ARG, turn Show Paren mode on if and only if ARG is positive.
104Returns the new status of Show Paren mode (non-nil means on). 90Returns the new status of Show Paren mode (non-nil means on).
105 91
106When Show Paren mode is enabled, any matching parenthesis is highlighted 92When Show Paren mode is enabled, any matching parenthesis is highlighted
107in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time." 93in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
108 (interactive "P") 94 nil nil nil :global t :group 'paren-showing
109 (let ((on-p (if arg
110 (> (prefix-numeric-value arg) 0)
111 (not show-paren-mode))))
112 (setq show-paren-mode on-p)
113 ;; Turn off the usual paren-matching method 95 ;; Turn off the usual paren-matching method
114 ;; when this one is turned on. 96 ;; when this one is turned on.
115 (if (local-variable-p 'show-paren-mode) 97 (if (local-variable-p 'show-paren-mode)
116 (make-local-variable 'blink-matching-paren-on-screen) 98 (make-local-variable 'blink-matching-paren-on-screen)
117 (kill-local-variable 'blink-matching-paren-on-screen)) 99 (kill-local-variable 'blink-matching-paren-on-screen))
118 (setq blink-matching-paren-on-screen (not on-p)) 100 (setq blink-matching-paren-on-screen (not show-paren-mode))
119 101
120 ;; Now enable or disable the mechanism. 102 ;; Now enable or disable the mechanism.
121 ;; First get rid of the old idle timer. 103 ;; First get rid of the old idle timer.
@@ -131,13 +113,13 @@ in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
131 (setq show-paren-idle-timer (run-with-idle-timer 113 (setq show-paren-idle-timer (run-with-idle-timer
132 show-paren-delay t 114 show-paren-delay t
133 'show-paren-function))) 115 'show-paren-function)))
134 (unless on-p 116 (unless show-paren-mode
135 (and show-paren-overlay 117 (and show-paren-overlay
136 (eq (overlay-buffer show-paren-overlay) (current-buffer)) 118 (eq (overlay-buffer show-paren-overlay) (current-buffer))
137 (delete-overlay show-paren-overlay)) 119 (delete-overlay show-paren-overlay))
138 (and show-paren-overlay-1 120 (and show-paren-overlay-1
139 (eq (overlay-buffer show-paren-overlay-1) (current-buffer)) 121 (eq (overlay-buffer show-paren-overlay-1) (current-buffer))
140 (delete-overlay show-paren-overlay-1))))) 122 (delete-overlay show-paren-overlay-1))))
141 123
142;; Find the place to show, if there is one, 124;; Find the place to show, if there is one,
143;; and show it until input arrives. 125;; and show it until input arrives.
@@ -244,7 +226,4 @@ in `show-paren-style' after `show-paren-delay' seconds of Emacs idle time."
244 226
245(provide 'paren) 227(provide 'paren)
246 228
247(if show-paren-mode
248 (show-paren-mode t))
249
250;;; paren.el ends here 229;;; paren.el ends here