diff 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
line wrap: on
line diff
--- a/lisp/packages/paren.el	Mon Aug 13 09:56:30 2007 +0200
+++ b/lisp/packages/paren.el	Mon Aug 13 09:57:07 2007 +0200
@@ -54,6 +54,36 @@
 
 ;;; Code:
 
+(defgroup paren-matching nil
+  "Highlight (un)matching of parens and expressions."
+  :prefix "paren-"
+  :group 'matching)
+
+
+;;;###autoload
+(defcustom paren-mode nil
+  "*Sets the style of parenthesis highlighting.
+Valid values are nil, `blink-paren', `paren', and `sexp'.
+  nil		no parenthesis highlighting.
+  blink-paren	causes the matching paren to blink.
+  paren		causes the matching paren to be highlighted but not to blink.
+  sexp		whole expression enclosed by the local paren at its mate.
+  nested	(not yet implemented) use variable shading to see the
+		nesting of an expression.  Also groks regular expressions
+		and shell quoting.
+
+This variable is global by default, but you can make it buffer-local and
+highlight parentheses differently in different major modes."
+  :type '(radio (const :tag "None (default)" nil)
+		(const :tag "Blinking Paren" blink-paren)
+		(const :tag "Highlighted Paren" paren)
+		(const :tag "Highlighted Expression" sexp))
+  :set (lambda (symbol value)
+	 (paren-set-mode value))
+  :initialize 'custom-initialize-default
+  :require 'paren
+  :group 'paren-matching)
+
 (defcustom paren-message-offscreen t
   "*Display message if matching open paren is offscreen."
   :type 'boolean
@@ -71,24 +101,6 @@
 		 (const :tag "other" other))
   :group 'paren-matching)
 
-;;;###autoload
-(defcustom paren-mode nil
-  "*Sets the style of parenthesis highlighting.
-Valid values are nil, `blink-paren', `paren', and `sexp'.
-  nil		no parenthesis highlighting.
-  blink-paren	causes the matching paren to blink.
-  paren		causes the matching paren to be highlighted but not to blink.
-  sexp		whole expression enclosed by the local paren at its mate.
-  nested	(not yet implemented) use variable shading to see the
-		nesting of an expression.  Also groks regular expressions
-		and shell quoting.
-
-This variable is global by default, but you can make it buffer-local and
-highlight parentheses differently in different major modes."
-  :type '(radio (const nil) (const blink-paren) (const paren)
-		(const sexp) (const nested))
-  :group 'paren-matching)
-
 (make-face 'paren-match)
 (or (face-differs-from-default-p 'paren-match)
     (copy-face 'highlight 'paren-match))
@@ -116,15 +128,19 @@
 ;; this is either paren-match or paren-mismatch...
 (defvar paren-blink-on-face nil)
 
-(defvar paren-blink-interval 0.2
+(defcustom paren-blink-interval 0.2
   "*If the cursor is on a parenthesis, the matching parenthesis will blink.
 This variable controls how long each phase of the blink lasts in seconds.
-This should be a fractional part of a second (a float.)")
+This should be a fractional part of a second (a float.)"
+  :type 'number
+  :group 'paren-matching)
 
-(defvar paren-max-blinks (* 5 60 5)	; 5 minutes is plenty...
+(defcustom paren-max-blinks (* 5 60 5)	; 5 minutes is plenty...
   ;; idea from Eric Eide <eeide@jaguar.cs.utah.edu>
   "*Maximum number of times that a matching parenthesis will blink.
-Set this to NIL if you want indefinite blinking.")
+Set this to NIL if you want indefinite blinking."
+  :type 'number
+  :group 'paren-matching)
 
 ;; timeout to blink the face
 (defvar paren-timeout-id nil)
@@ -310,10 +326,6 @@
 					    paren-blink-interval))))))
 	))))
 
-;; kill off the competition, er, uh, eliminate redundancy...
-(setq post-command-hook (delq 'show-paren-command-hook post-command-hook))
-(setq pre-command-hook (delq 'blink-paren-pre-command pre-command-hook))
-(setq post-command-hook (delq 'blink-paren-post-command post-command-hook))
 
 ;;;###autoload
 (defun paren-set-mode (arg &optional quiet)
@@ -321,6 +333,11 @@
 When called from lisp, a symbolic value for `paren-mode' can be passed directly.
 See also `paren-mode' and `paren-highlight'."
   (interactive "P")
+  ;; kill off the competition, er, uh, eliminate redundancy...
+  (setq post-command-hook (delq 'show-paren-command-hook post-command-hook))
+  (setq pre-command-hook (delq 'blink-paren-pre-command pre-command-hook))
+  (setq post-command-hook (delq 'blink-paren-post-command post-command-hook))
+
   (let* ((paren-modes '(blink-paren paren sexp))
 	 (paren-next-modes (cons nil (append paren-modes (list nil)))))
     (setq paren-mode (if (and (numberp arg) (< arg 0))
@@ -348,14 +365,15 @@
   ;; suppress compiler warning.
   (defvar highlight-paren-expression))
 
-(paren-set-mode (if (and (boundp 'highlight-paren-expression)
-			    ;; bletcherous blink-paren no-naming-convention
-			    highlight-paren-expression)
-		       'sexp
-		     (if (eq 'x (device-type (selected-device)))
-			 'blink-paren
-		       'paren))
-		t)
+;; No no no!
+;(paren-set-mode (if (and (boundp 'highlight-paren-expression)
+;			    ;; bletcherous blink-paren no-naming-convention
+;			    highlight-paren-expression)
+;		       'sexp
+;		     (if (eq 'x (device-type (selected-device)))
+;			 'blink-paren
+;		       'paren))
+;		t)
 
 ;;;###autoload
 (make-obsolete 'blink-paren 'paren-set-mode)