comparison lisp/packages/mic-paren.el @ 12:bcdc7deadc19 r19-15b7

Import from CVS: tag r19-15b7
author cvs
date Mon, 13 Aug 2007 08:48:16 +0200
parents 27bc7f280385
children 4103f0995bd7
comparison
equal deleted inserted replaced
11:91ffe8bd52e4 12:bcdc7deadc19
1 ;;; mic-paren.el --- highlight matching paren. 1 ;;; mic-paren.el --- highlight matching paren.
2 ;;; Version 1.0 - 96-08-16 2 ;;; Version 1.2 - 96-09-19
3 ;;; Copyright (C) 1996 Mikael Sjödin (mic@docs.uu.se) 3 ;;; Copyright (C) 1996 Mikael Sj,Av(Bdin (mic@docs.uu.se)
4 ;;; 4 ;;;
5 ;;; Author: Mikael Sjödin -- mic@docs.uu.se 5 ;;; Author: Mikael Sj,Av(Bdin -- mic@docs.uu.se
6 ;;; Keywords: languages, faces 6 ;;; Keywords: languages, faces
7 ;;; 7 ;;;
8 ;;; This file is NOT part of GNU Emacs. 8 ;;; This file is NOT part of GNU Emacs.
9 ;;; You may however redistribute it and/or modify it under the terms of the GNU 9 ;;; You may however redistribute it and/or modify it under the terms of the GNU
10 ;;; General Public License as published by the Free Software Foundation; either 10 ;;; General Public License as published by the Free Software Foundation; either
43 ;;; parenthesis matching is deactivated. Instead parenthesis matching will be 43 ;;; parenthesis matching is deactivated. Instead parenthesis matching will be
44 ;;; performed as soon as the cursor is positioned at a parenthesis. The 44 ;;; performed as soon as the cursor is positioned at a parenthesis. The
45 ;;; matching parenthesis (or the entire expression between the parenthesises) 45 ;;; matching parenthesis (or the entire expression between the parenthesises)
46 ;;; is highlighted until the cursor is moved away from the parenthesis. 46 ;;; is highlighted until the cursor is moved away from the parenthesis.
47 ;;; Features include: 47 ;;; Features include:
48 ;;; o Both forward and backward parenthesis matching (_simultaneously_ if 48 ;;; o Both forward and backward parenthesis matching (simultaneously if
49 ;;; cursor is between two expressions). 49 ;;; cursor is between two expressions).
50 ;;; o Indication of mismatched parenthesises. 50 ;;; o Indication of mismatched parenthesises.
51 ;;; o Recognition of "escaped" parenthesises.
51 ;;; o Option to select if only the matching parenthesis or the entire 52 ;;; o Option to select if only the matching parenthesis or the entire
52 ;;; expression should be highlighted. 53 ;;; expression should be highlighted.
53 ;;; o Message describing the match when the matching parenthesis is 54 ;;; o Message describing the match when the matching parenthesis is
54 ;;; off-screen. 55 ;;; off-screen.
55 ;;; o Optional delayed highlighting (useful on slow systems), 56 ;;; o Optional delayed highlighting (useful on slow systems),
56 ;;; o Functions to activate/deactivate mic-paren.el is provided. 57 ;;; o Functions to activate/deactivate mic-paren.el is provided.
57 ;;; o Numerous options to control the behaviour and appearance of 58 ;;; o Numerous options to control the behaviour and appearance of
58 ;;; mic-paren.el. 59 ;;; mic-paren.el.
59 ;;; 60 ;;;
60 ;;; mic-paren.el is developed and tested under Emacs 19.28 - 19.31. It should 61 ;;; mic-paren.el is developed and tested under Emacs 19.28 - 19.34. It should
61 ;;; work on earlier and forthcoming Emacs versions. 62 ;;; work on earlier and forthcoming Emacs versions. XEmacs compatibility has
63 ;;; been provided by Steven L Baur <steve@altair.xemacs.org>.
62 ;;; 64 ;;;
63 ;;; This file can be obtained from http://www.docs.uu.se/~mic/emacs.html 65 ;;; This file can be obtained from http://www.docs.uu.se/~mic/emacs.html
64 66
65 ;; Ported to XEmacs 15-September, 1996 Steve Baur <steve@miranova.com>
66 ;;; ====================================================================== 67 ;;; ======================================================================
67 ;;; User Options: 68 ;;; User Options:
68 69
69 (defvar paren-priority nil 70 (defvar paren-priority nil
70 "*Defines the behaviour of mic-paren when point is between a closing and an 71 "*Defines the behaviour of mic-paren when point is between a closing and an
179 "*Face to use when highlighting a mismatched parenthesis.") 180 "*Face to use when highlighting a mismatched parenthesis.")
180 181
181 ;;; ====================================================================== 182 ;;; ======================================================================
182 ;;; User Functions: 183 ;;; User Functions:
183 184
184 ;; XEmacs compatibility 185 ;; XEmacs compatibility (by Steven L Baur <steve@altair.xemacs.org>)
185 (eval-and-compile 186 (eval-and-compile
186 (if (fboundp 'make-extent) 187 (if (fboundp 'make-extent)
187 (progn 188 (progn
188 (fset 'mic-make-overlay 'make-extent) 189 (fset 'mic-make-overlay 'make-extent)
189 (fset 'mic-delete-overlay 'delete-extent) 190 (fset 'mic-delete-overlay 'delete-extent)
238 (remove-hook 'pre-command-hook 'stig-paren-delete-overlay) 239 (remove-hook 'pre-command-hook 'stig-paren-delete-overlay)
239 ;; Deactivate Emacs standard parenthesis blinking 240 ;; Deactivate Emacs standard parenthesis blinking
240 (or paren-dont-touch-blink 241 (or paren-dont-touch-blink
241 (setq blink-matching-paren nil)) 242 (setq blink-matching-paren nil))
242 243
243 (cond 244 (cond(
244 ;; If timers are available use them 245 ;; If timers are available use them
245 ;; (Emacs 19.31 and above) 246 ;; (Emacs 19.31 and above)
246 ((or (featurep 'timer) (featurep 'itimer)) 247 (featurep 'timer)
247 (if (numberp paren-delay) 248 (if (numberp paren-delay)
248 (setq mic-paren-idle-timer 249 (setq mic-paren-idle-timer
249 (mic-run-with-idle-timer paren-delay t 250 (mic-run-with-idle-timer paren-delay t
250 'mic-paren-command-idle-hook)) 251 'mic-paren-command-idle-hook))
251 (add-hook 'post-command-hook 'mic-paren-command-hook))) 252 (add-hook 'post-command-hook 'mic-paren-command-hook)))
252 ;; If the idle hook exists assume it is functioning and use it 253 ;; If the idle hook exists assume it is functioning and use it
253 ;; (Emacs 19.30) 254 ;; (Emacs 19.30)
254 ((and (boundp 'post-command-idle-hook) 255 ((and (boundp 'post-command-idle-hook)
255 (boundp 'post-command-idle-delay)) 256 (boundp 'post-command-idle-delay))
256 (if paren-delay 257 (if paren-delay