Mercurial > hg > xemacs-beta
comparison lisp/packages/paren.el @ 189:489f57a838ef r20-3b21
Import from CVS: tag r20-3b21
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:57:07 +0200 |
parents | 1370575f1259 |
children |
comparison
equal
deleted
inserted
replaced
188:e29a8e7498d9 | 189:489f57a838ef |
---|---|
52 ;; If paren-mode is `sexp', entire S-expressions are highlighted instead of | 52 ;; If paren-mode is `sexp', entire S-expressions are highlighted instead of |
53 ;; just matching parens. | 53 ;; just matching parens. |
54 | 54 |
55 ;;; Code: | 55 ;;; Code: |
56 | 56 |
57 (defcustom paren-message-offscreen t | 57 (defgroup paren-matching nil |
58 "*Display message if matching open paren is offscreen." | 58 "Highlight (un)matching of parens and expressions." |
59 :type 'boolean | 59 :prefix "paren-" |
60 :group 'paren-matching) | 60 :group 'matching) |
61 | 61 |
62 (defcustom paren-ding-unmatched nil | |
63 "*Make noise if the cursor is at an unmatched paren. | |
64 | |
65 If T, then typing or passing over an unmatched paren will ring the bell | |
66 using the `paren' sound. If NIL, then the bell will not ring even if an | |
67 unmatched paren is typed. If neither T or NIL, then the bell will not ring | |
68 when the cursor moves over unmatched parens but will ring if one is typed." | |
69 :type '(choice (const :tag "off" nil) | |
70 (const :tag "on" t) | |
71 (const :tag "other" other)) | |
72 :group 'paren-matching) | |
73 | 62 |
74 ;;;###autoload | 63 ;;;###autoload |
75 (defcustom paren-mode nil | 64 (defcustom paren-mode nil |
76 "*Sets the style of parenthesis highlighting. | 65 "*Sets the style of parenthesis highlighting. |
77 Valid values are nil, `blink-paren', `paren', and `sexp'. | 66 Valid values are nil, `blink-paren', `paren', and `sexp'. |
83 nesting of an expression. Also groks regular expressions | 72 nesting of an expression. Also groks regular expressions |
84 and shell quoting. | 73 and shell quoting. |
85 | 74 |
86 This variable is global by default, but you can make it buffer-local and | 75 This variable is global by default, but you can make it buffer-local and |
87 highlight parentheses differently in different major modes." | 76 highlight parentheses differently in different major modes." |
88 :type '(radio (const nil) (const blink-paren) (const paren) | 77 :type '(radio (const :tag "None (default)" nil) |
89 (const sexp) (const nested)) | 78 (const :tag "Blinking Paren" blink-paren) |
79 (const :tag "Highlighted Paren" paren) | |
80 (const :tag "Highlighted Expression" sexp)) | |
81 :set (lambda (symbol value) | |
82 (paren-set-mode value)) | |
83 :initialize 'custom-initialize-default | |
84 :require 'paren | |
85 :group 'paren-matching) | |
86 | |
87 (defcustom paren-message-offscreen t | |
88 "*Display message if matching open paren is offscreen." | |
89 :type 'boolean | |
90 :group 'paren-matching) | |
91 | |
92 (defcustom paren-ding-unmatched nil | |
93 "*Make noise if the cursor is at an unmatched paren. | |
94 | |
95 If T, then typing or passing over an unmatched paren will ring the bell | |
96 using the `paren' sound. If NIL, then the bell will not ring even if an | |
97 unmatched paren is typed. If neither T or NIL, then the bell will not ring | |
98 when the cursor moves over unmatched parens but will ring if one is typed." | |
99 :type '(choice (const :tag "off" nil) | |
100 (const :tag "on" t) | |
101 (const :tag "other" other)) | |
90 :group 'paren-matching) | 102 :group 'paren-matching) |
91 | 103 |
92 (make-face 'paren-match) | 104 (make-face 'paren-match) |
93 (or (face-differs-from-default-p 'paren-match) | 105 (or (face-differs-from-default-p 'paren-match) |
94 (copy-face 'highlight 'paren-match)) | 106 (copy-face 'highlight 'paren-match)) |
114 (set-face-foreground 'paren-blink-off (face-background 'default))) | 126 (set-face-foreground 'paren-blink-off (face-background 'default))) |
115 | 127 |
116 ;; this is either paren-match or paren-mismatch... | 128 ;; this is either paren-match or paren-mismatch... |
117 (defvar paren-blink-on-face nil) | 129 (defvar paren-blink-on-face nil) |
118 | 130 |
119 (defvar paren-blink-interval 0.2 | 131 (defcustom paren-blink-interval 0.2 |
120 "*If the cursor is on a parenthesis, the matching parenthesis will blink. | 132 "*If the cursor is on a parenthesis, the matching parenthesis will blink. |
121 This variable controls how long each phase of the blink lasts in seconds. | 133 This variable controls how long each phase of the blink lasts in seconds. |
122 This should be a fractional part of a second (a float.)") | 134 This should be a fractional part of a second (a float.)" |
123 | 135 :type 'number |
124 (defvar paren-max-blinks (* 5 60 5) ; 5 minutes is plenty... | 136 :group 'paren-matching) |
137 | |
138 (defcustom paren-max-blinks (* 5 60 5) ; 5 minutes is plenty... | |
125 ;; idea from Eric Eide <eeide@jaguar.cs.utah.edu> | 139 ;; idea from Eric Eide <eeide@jaguar.cs.utah.edu> |
126 "*Maximum number of times that a matching parenthesis will blink. | 140 "*Maximum number of times that a matching parenthesis will blink. |
127 Set this to NIL if you want indefinite blinking.") | 141 Set this to NIL if you want indefinite blinking." |
142 :type 'number | |
143 :group 'paren-matching) | |
128 | 144 |
129 ;; timeout to blink the face | 145 ;; timeout to blink the face |
130 (defvar paren-timeout-id nil) | 146 (defvar paren-timeout-id nil) |
131 | 147 |
132 ;; Code: | 148 ;; Code: |
308 'paren-blink-timeout | 324 'paren-blink-timeout |
309 nil | 325 nil |
310 paren-blink-interval)))))) | 326 paren-blink-interval)))))) |
311 )))) | 327 )))) |
312 | 328 |
313 ;; kill off the competition, er, uh, eliminate redundancy... | |
314 (setq post-command-hook (delq 'show-paren-command-hook post-command-hook)) | |
315 (setq pre-command-hook (delq 'blink-paren-pre-command pre-command-hook)) | |
316 (setq post-command-hook (delq 'blink-paren-post-command post-command-hook)) | |
317 | 329 |
318 ;;;###autoload | 330 ;;;###autoload |
319 (defun paren-set-mode (arg &optional quiet) | 331 (defun paren-set-mode (arg &optional quiet) |
320 "Cycles through possible values for `paren-mode', force off with negative arg. | 332 "Cycles through possible values for `paren-mode', force off with negative arg. |
321 When called from lisp, a symbolic value for `paren-mode' can be passed directly. | 333 When called from lisp, a symbolic value for `paren-mode' can be passed directly. |
322 See also `paren-mode' and `paren-highlight'." | 334 See also `paren-mode' and `paren-highlight'." |
323 (interactive "P") | 335 (interactive "P") |
336 ;; kill off the competition, er, uh, eliminate redundancy... | |
337 (setq post-command-hook (delq 'show-paren-command-hook post-command-hook)) | |
338 (setq pre-command-hook (delq 'blink-paren-pre-command pre-command-hook)) | |
339 (setq post-command-hook (delq 'blink-paren-post-command post-command-hook)) | |
340 | |
324 (let* ((paren-modes '(blink-paren paren sexp)) | 341 (let* ((paren-modes '(blink-paren paren sexp)) |
325 (paren-next-modes (cons nil (append paren-modes (list nil))))) | 342 (paren-next-modes (cons nil (append paren-modes (list nil))))) |
326 (setq paren-mode (if (and (numberp arg) (< arg 0)) | 343 (setq paren-mode (if (and (numberp arg) (< arg 0)) |
327 nil ; turn paren highlighting off | 344 nil ; turn paren highlighting off |
328 (cond ((and arg (symbolp arg)) arg) | 345 (cond ((and arg (symbolp arg)) arg) |
346 | 363 |
347 (eval-when-compile | 364 (eval-when-compile |
348 ;; suppress compiler warning. | 365 ;; suppress compiler warning. |
349 (defvar highlight-paren-expression)) | 366 (defvar highlight-paren-expression)) |
350 | 367 |
351 (paren-set-mode (if (and (boundp 'highlight-paren-expression) | 368 ;; No no no! |
352 ;; bletcherous blink-paren no-naming-convention | 369 ;(paren-set-mode (if (and (boundp 'highlight-paren-expression) |
353 highlight-paren-expression) | 370 ; ;; bletcherous blink-paren no-naming-convention |
354 'sexp | 371 ; highlight-paren-expression) |
355 (if (eq 'x (device-type (selected-device))) | 372 ; 'sexp |
356 'blink-paren | 373 ; (if (eq 'x (device-type (selected-device))) |
357 'paren)) | 374 ; 'blink-paren |
358 t) | 375 ; 'paren)) |
376 ; t) | |
359 | 377 |
360 ;;;###autoload | 378 ;;;###autoload |
361 (make-obsolete 'blink-paren 'paren-set-mode) | 379 (make-obsolete 'blink-paren 'paren-set-mode) |
362 | 380 |
363 ;;;###autoload | 381 ;;;###autoload |