[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3b75d95 005/110: Make "C-g" and "ESC" fail silently when r
From: |
Oleh Krehel |
Subject: |
[elpa] master 3b75d95 005/110: Make "C-g" and "ESC" fail silently when reading char |
Date: |
Sat, 11 May 2019 10:15:33 -0400 (EDT) |
branch: master
commit 3b75d9520d76711f2e9b6505403a241c31022115
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make "C-g" and "ESC" fail silently when reading char
* avy.el (avy-ignored-modes): Add type.
(avy-handler-default): Silence "C-g" and "ESC".
(avy-goto-line): Call `avy-handler-function' instead of
`avy-handler-default'.
(avy-timeout-seconds): Add type.
Fixes #137
---
avy.el | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/avy.el b/avy.el
index ff45502..78e5d63 100644
--- a/avy.el
+++ b/avy.el
@@ -165,7 +165,8 @@ When nil, punctuation chars will not be matched.
(defcustom avy-ignored-modes '(image-mode doc-view-mode pdf-view-mode)
"List of modes to ignore when searching for candidates.
-Typically, these modes don't use the text representation.")
+Typically, these modes don't use the text representation."
+ :type 'list)
(defvar avy-ring (make-ring 20)
"Hold the window and point history.")
@@ -352,12 +353,15 @@ KEYS is the path from the root of `avy-tree' to LEAF."
(defun avy-handler-default (char)
"The default handler for a bad CHAR."
(let (dispatch)
- (if (setq dispatch (assoc char avy-dispatch-alist))
- (progn
- (setq avy-action (cdr dispatch))
- (throw 'done 'restart))
- (signal 'user-error (list "No such candidate" char))
- (throw 'done nil))))
+ (cond ((setq dispatch (assoc char avy-dispatch-alist))
+ (setq avy-action (cdr dispatch))
+ (throw 'done 'restart))
+ ((memq char '(27 ?\C-g))
+ ;; exit silently
+ (throw 'done 'exit))
+ (t
+ (signal 'user-error (list "No such candidate" char))
+ (throw 'done nil)))))
(defvar avy-handler-function 'avy-handler-default
"A function to call for a bad `read-key' in `avy-read'.")
@@ -1090,11 +1094,12 @@ Otherwise, forward to `goto-line' with ARG."
(goto-char (point-min))
(forward-line (1- arg)))
(avy-with avy-goto-line
- (let* ((avy-handler-function
+ (let* ((avy-handler-old avy-handler-function)
+ (avy-handler-function
(lambda (char)
(if (or (< char ?0)
(> char ?9))
- (avy-handler-default char)
+ (funcall avy-handler-old char)
(let ((line (read-from-minibuffer
"Goto line: " (string char))))
(when line
@@ -1223,7 +1228,8 @@ The window scope is determined by `avy-all-windows' or
'(define-key isearch-mode-map (kbd "C-'") 'avy-isearch)))
(defcustom avy-timeout-seconds 0.5
- "How many seconds to wait for the second char.")
+ "How many seconds to wait for the second char."
+ :type 'float)
(defun avy--read-candidates ()
"Read as many chars as possible and return their occurences.
- [elpa] master ba950a0 015/110: avy.el (avy-goto-char-2-above): Add, (continued)
- [elpa] master ba950a0 015/110: avy.el (avy-goto-char-2-above): Add, Oleh Krehel, 2019/05/11
- [elpa] master 58bc417 014/110: Escape regex metacharacters for standard isearch, Oleh Krehel, 2019/05/11
- [elpa] master 2e3c2f7 013/110: Add new command `avy-move-region', Oleh Krehel, 2019/05/11
- [elpa] master 85a384a 012/110: Add char at window start for avy-goto-subword-0, Oleh Krehel, 2019/05/11
- [elpa] master a80f95c 007/110: Add "X" dispatch to kill a word without moving there, Oleh Krehel, 2019/05/11
- [elpa] master 9e61f78 006/110: avy.el: Improve defcustom :type, Oleh Krehel, 2019/05/11
- [elpa] master 5ba3602 009/110: Assign avy-action-ispell to "i", Oleh Krehel, 2019/05/11
- [elpa] master 53706d2 011/110: avy.el (avy-all-windows-alt): Change the default to nil, Oleh Krehel, 2019/05/11
- [elpa] master 4c072be 010/110: README.md (avy-goto-char-timer): Add entry, Oleh Krehel, 2019/05/11
- [elpa] master c0db364 008/110: Add avy-action-ispell to avy.el, Oleh Krehel, 2019/05/11
- [elpa] master 3b75d95 005/110: Make "C-g" and "ESC" fail silently when reading char,
Oleh Krehel <=
- [elpa] master 5f76c9d 004/110: avy.el (avy-goto-word-0-regexp): New defcustom, Oleh Krehel, 2019/05/11
- [elpa] master 5f6dd00 001/110: avy.el (avy-action-copy): Save window and frame, Oleh Krehel, 2019/05/11
- [elpa] master 16370f9 003/110: avy.el (avy--goto): Remove obsolete alias, Oleh Krehel, 2019/05/11
- [elpa] master 730581a 002/110: avy.el: Fix compilation warning, Oleh Krehel, 2019/05/11