From bca96ae3b4d7124875374055c5d11fd722b338ca Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Fri, 8 May 2015 18:19:40 +0200 Subject: [PATCH] Add avy-goto-char-timer avy-jump.el (avy-goto-char-timer): New command. Generalize `avy-goto-char' and `avy-goto-char-2' with a timer. * avy-jump.el (avy-timeout-seconds): New defcustom. Fixes #13 --- avy-jump.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/avy-jump.el b/avy-jump.el index b0a1ba8..444b27a 100644 --- a/avy-jump.el +++ b/avy-jump.el @@ -442,6 +442,24 @@ ARG lines can be used." (eval-after-load 'isearch '(define-key isearch-mode-map (kbd "C-'") 'avy-isearch))) +(defcustom avy-timeout-seconds 0.5 + "How many seconds to wait for the second char.") + +;;;###autoload +(defun avy-goto-char-timer (&optional arg) + "Read one or two consecutive chars and jump to the first one. +The window scope is determined by `avy-all-windows' (ARG negates it)." + (interactive "P") + (let ((c1 (read-char "char 1: ")) + (c2 (read-char "char 2: " nil avy-timeout-seconds))) + (avy--generic-jump + (regexp-quote + (if c2 + (string c1 c2) + (string c1))) + arg + avy-goto-char-style))) + (define-obsolete-variable-alias 'avi-keys 'avy-keys "0.1.0") (define-obsolete-variable-alias 'avi-background 'avy-background "0.1.0") (define-obsolete-variable-alias 'avi-word-punc-regexp 'avy-word-punc-regexp "0.1.0")