[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/easy-kill 5b4ae1e 13/14: Introduce easy-kill-cycle-igno
From: |
Stefan Monnier |
Subject: |
[elpa] externals/easy-kill 5b4ae1e 13/14: Introduce easy-kill-cycle-ignored to opt out of cycling |
Date: |
Mon, 15 Mar 2021 22:20:17 -0400 (EDT) |
branch: externals/easy-kill
commit 5b4ae1e33e0307a42df0440cc10004d812a6b70a
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>
Introduce easy-kill-cycle-ignored to opt out of cycling
---
easy-kill.el | 25 +++++++++++++++++++------
test.el | 21 +++++++++++++++++++++
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index 1ec03fd..455c58e 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -91,6 +91,11 @@ deprecated."
(choice string (const :tag "None" nil))))
:group 'killing)
+(defcustom easy-kill-cycle-ignored nil
+ "A list of things that `easy-kill-cycle' should ignore."
+ :type '(repeat symbol)
+ :group 'killing)
+
(defcustom easy-kill-unhighlight-key nil
"Key sequence if non-nil to unhighlight the kill candidate."
:type '(choice (const :tag "None" nil) key-sequence)
@@ -389,21 +394,28 @@ candidate property instead."
(easy-kill-thing nil '+))
(defun easy-kill-cycle (&optional thing)
- "Cycle through things in `easy-kill-alist'."
+ "Cycle through things in `easy-kill-alist'.
+A thing is opted out of cycling if in `easy-kill-cycle-ignored'."
(interactive)
- (let ((next (easy-kill-cycle-next (or thing (easy-kill-get thing)))))
+ (let ((next (easy-kill-cycle-next (or thing (easy-kill-get thing))
+ (length easy-kill-cycle-ignored))))
(easy-kill-thing next)
(if (eq next (easy-kill-get thing))
(easy-kill-echo "%s" next)
;; NEXT not killable continue cycle.
(easy-kill-cycle next))))
-(defun easy-kill-cycle-next (thing)
+(defun easy-kill-cycle-next (thing depth)
(cl-flet ((thing-name (thing)
(if (symbolp (cdr thing)) (cdr thing) (cl-second thing))))
- (cl-loop for (head . tail) on easy-kill-alist
- when (eq thing (thing-name head))
- return (thing-name (car (or tail easy-kill-alist))))))
+ (let ((next (thing-name
+ (car (or (cl-loop for (head . tail) on easy-kill-alist
+ when (eq thing (thing-name head))
+ return tail)
+ easy-kill-alist)))))
+ (cond ((not (memq next easy-kill-cycle-ignored)) next)
+ ((> depth 0) (easy-kill-cycle-next next (1- depth)))
+ (t (user-error "Nothing to cycle"))))))
(defun easy-kill-digit-argument (n)
"Expand selection by N number of things.
@@ -608,6 +620,7 @@ Temporally activate additional key bindings as follows:
@ => append selection to previous kill;
? => help;
C-w => kill selection;
+ SPC => cycle through things in `easy-kill-alist';
C-SPC => turn selection into an active region;
C-g => abort;
others => save selection and exit."
diff --git a/test.el b/test.el
index 599920a..5dc5392 100644
--- a/test.el
+++ b/test.el
@@ -443,4 +443,25 @@ some of the ways to customize it;
(should (= (mark t) (easy-kill-get start)))
(should (= (point) (easy-kill-get end))))))
+(ert-deftest test-easy-kill-cycle ()
+ (let ((easy-kill-alist '((?w word) (?s sexp))))
+ (with-temp-buffer
+ (insert "a@example.com")
+ (call-interactively 'easy-kill)
+ (should (eq 'email (easy-kill-get thing)))
+
+ (call-interactively 'easy-kill-cycle)
+ (should (eq 'word (easy-kill-get thing)))
+ (call-interactively 'easy-kill-cycle)
+ (should (eq 'sexp (easy-kill-get thing)))
+ (call-interactively 'easy-kill-cycle)
+ (should (eq 'word (easy-kill-get thing)))
+
+ (let ((easy-kill-cycle-ignored '(sexp)))
+ (call-interactively 'easy-kill-cycle))
+ (should (eq 'word (easy-kill-get thing)))
+
+ (let ((easy-kill-cycle-ignored '(word sexp)))
+ (should-error (call-interactively 'easy-kill-cycle))))))
+
;;; test.el ends here
- [elpa] externals/easy-kill bf28f77 04/14: Add `D' for selecting current defun name, (continued)
- [elpa] externals/easy-kill bf28f77 04/14: Add `D' for selecting current defun name, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 5060d01 11/14: Fix #29: New command easy-kill-cycle, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 3ca8018 05/14: Check boundary in easy-kill-bounds-of-thing-at-point, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill e2b667f 10/14: Merge pull request #27 from syohex/fix-doc, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill c73aa3b 12/14: New macro easy-kill-defun to simplify defining some commands, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 7056376 07/14: Fix #25: Avoid using `<=' feature from 24.4, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 2a6309d 14/14: Limit easy-kill-exchange-point-and-mark to easy-mark only, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill af56568 08/14: Fix #26: Make easy-kill-unhighlight save selection candidate, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 5226660 01/14: Fix #16: New user variable easy-kill-unhighlight-key, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 17994a0 09/14: Fix document, Stefan Monnier, 2021/03/15
- [elpa] externals/easy-kill 5b4ae1e 13/14: Introduce easy-kill-cycle-ignored to opt out of cycling,
Stefan Monnier <=
- [elpa] externals/easy-kill cf5488a 06/14: Merge pull request #20 from knu/delete-region, Stefan Monnier, 2021/03/15