diff options
author | Richard M. Stallman <rms@gnu.org> | 1996-02-28 01:28:42 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1996-02-28 01:28:42 +0000 |
commit | 673cc3c51d87926c7a320557022f82ae6c6a2778 (patch) | |
tree | 41d0b87cacf8cfd39830d54855cfc00b7136c06e /lisp/paren.el | |
parent | cf9b15ce3777f285fd029b2dbda5987d2ca6392e (diff) | |
download | emacs-673cc3c51d87926c7a320557022f82ae6c6a2778.tar.gz |
(show-paren-delay): New variable.
(show-paren-mode): New command. Use it. Call it at the top-level.
(show-paren-mode, show-paren-idle-timer): New variables.
(show-paren-function): Renamed from show-paren-command-hook.
Diffstat (limited to 'lisp/paren.el')
-rw-r--r-- | lisp/paren.el | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/lisp/paren.el b/lisp/paren.el index e556b6c646c..cad0116fa71 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -1,6 +1,6 @@ ;;; paren.el --- highlight matching paren. -;; Copyright (C) 1993 Free Software Foundation, Inc. +;; Copyright (C) 1993, 1996 Free Software Foundation, Inc. ;; Author: rms@gnu.ai.mit.edu ;; Maintainer: FSF @@ -32,18 +32,47 @@ ;; This is the overlay used to highlight the matching paren. (defvar show-paren-overlay nil) -;; This is the overlay used to highlight the closeparen -;; right before point. +;; This is the overlay used to highlight the closeparen right before point. (defvar show-paren-overlay-1 nil) +(defvar show-paren-mode nil) +(defvar show-paren-idle-timer nil) + (defvar show-paren-mismatch-face nil) +(defvar show-paren-delay (if (featurep 'lisp-float-type) 0.125 1) + "*Time in seconds to delay before showing the matching paren.") + (defvar show-paren-face 'region - "*Name of face to use for showing the matching paren.") + "*Name of the face to use for showing the matching paren.") + +;;;###autoload +(defun show-paren-mode (&optional arg) + "Toggle Show Paren mode. +With prefix ARG, turn Show Paren mode on if and only if ARG is positive. +Returns the new status of Show Paren mode (non-nil means on). + +When Show Paren mode is enabled, any matching parenthesis is highlighted +after `show-paren-delay' seconds of Emacs idle time." + (interactive "P") + (if window-system + (let ((on-p (if arg + (> (prefix-numeric-value arg) 0) + (not show-paren-mode)))) + (setq blink-matching-paren-on-screen (not on-p)) + (and show-paren-idle-timer (cancel-timer show-paren-idle-timer)) + (if on-p + (setq show-paren-idle-timer (run-with-idle-timer show-paren-delay t + 'show-paren-function)) + (and show-paren-overlay (overlay-buffer show-paren-overlay) + (delete-overlay show-paren-overlay)) + (and show-paren-overlay-1 (overlay-buffer show-paren-overlay-1) + (delete-overlay show-paren-overlay-1))) + (setq show-paren-mode on-p)))) ;; Find the place to show, if there is one, ;; and show it until input arrives. -(defun show-paren-command-hook () +(defun show-paren-function () ;; Do nothing if no window system to display results with. ;; Do nothing if executing keyboard macro. ;; Do nothing if input is pending. @@ -130,17 +159,10 @@ (and show-paren-overlay-1 (overlay-buffer show-paren-overlay-1) (delete-overlay show-paren-overlay-1))))))) -(if window-system - (progn - (setq blink-matching-paren-on-screen nil) - (run-with-idle-timer .1 t 'show-paren-command-hook))) -;;; This is in case paren.el is preloaded. -(add-hook 'window-setup-hook - (function (lambda () - (if window-system - (progn - (setq blink-matching-paren-on-screen nil) - (run-with-idle-timer .1 t 'show-paren-command-hook)))))) +;;; For back compatibility we turn ourselves on if we're dumped or loaded. +(add-hook 'window-setup-hook 'show-paren-mode) +(show-paren-mode t) + (provide 'paren) ;;; paren.el ends here |