all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* show-paren-timeout
@ 2005-03-11  2:30 August Karlstrom
  2005-03-11 19:37 ` show-paren-timeout August Karlstrom
  0 siblings, 1 reply; 2+ messages in thread
From: August Karlstrom @ 2005-03-11  2:30 UTC (permalink / raw)


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'.

-- 
August

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: show-paren-timeout
  2005-03-11  2:30 show-paren-timeout August Karlstrom
@ 2005-03-11 19:37 ` August Karlstrom
  0 siblings, 0 replies; 2+ messages in thread
From: August Karlstrom @ 2005-03-11 19:37 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-11 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-11  2:30 show-paren-timeout August Karlstrom
2005-03-11 19:37 ` show-paren-timeout August Karlstrom

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.