On fre, 2005-03-11 at 03:30 +0100, August Karlstrom wrote:
> Does anyone know if there's a way to customize `show-paren-mode' so that
> any matching parenthesis is highlighted, but only for a limited amount
> of time, say one second? I find it annoying that the highlighting
> doesn't go away when I leave the cursor beside a parenthesis. There is
> an option called `show-paren-delay' but no `show-paren-timeout'.
I fixed it myself. If anyone's interested here's the code I added to
`.emacs':
;; SHOW PAREN MODE CUSTOMIZATION
(defconst my-show-paren-timeout 1
"*Time in seconds until a matching paren is unhighlighted.")
(defvar my-show-paren-timeout-timer nil
"*Timer used by advice `timeout' of `show-paren-function'.")
(defvar my-show-paren-timeout-saved-point nil
"*Location used by advice `timeout' of `show-paren-function'.")
(require 'advice)
(defadvice show-paren-function (after timeout)
"Unhighlight matching paren after `my-show-paren-timeout' seconds."
(if (and (integerp my-show-paren-timeout-saved-point)
(= (point) my-show-paren-timeout-saved-point))
(progn (delete-overlay show-paren-overlay)
(delete-overlay show-paren-overlay-1))
(setq my-show-paren-timeout-saved-point (point))
(setq my-show-paren-timeout-timer
(run-with-idle-timer my-show-paren-timeout nil
(lambda ()
(when (= (point)
my-show-paren-timeout-saved-
point)
(delete-overlay show-paren-overlay)
(delete-overlay show-paren-
overlay-1)))))))
(ad-activate 'show-paren-function)
--
August
_______________________________________________
Help-gnu-emacs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs