emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/easy-kill 5060d01 11/14: Fix #29: New command easy-kill


From: Stefan Monnier
Subject: [elpa] externals/easy-kill 5060d01 11/14: Fix #29: New command easy-kill-cycle
Date: Mon, 15 Mar 2021 22:20:17 -0400 (EDT)

branch: externals/easy-kill
commit 5060d016012205db95fe961147d75ef71281e29b
Author: Leo Liu <sdl.web@gmail.com>
Commit: Leo Liu <sdl.web@gmail.com>

    Fix #29: New command easy-kill-cycle
---
 README.rst   |  2 ++
 easy-kill.el | 20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/README.rst b/README.rst
index f5b024e..400984f 100644
--- a/README.rst
+++ b/README.rst
@@ -43,6 +43,7 @@ The following keys modify the selection:
 #. ``+``, ``-`` and ``1..9``: expand/shrink selection
 #. ``0`` shrink the selection to the initial size i.e. before any
    expansion
+#. ``SPC``: cycle through things in ``easy-kill-alist``
 #. ``C-SPC``: turn selection into an active region
 #. ``C-g``: abort
 #. ``?``: help
@@ -101,6 +102,7 @@ NEWS
 
 #. New user variable ``easy-kill-unhighlight-key``.
 #. key ``D`` selects current defun name.
+#. Key ``SPC`` selects things in ``easy-kill-alist`` in turn.
 
 0.9.3
 +++++
diff --git a/easy-kill.el b/easy-kill.el
index 07d63ea..068a546 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -1,6 +1,6 @@
 ;;; easy-kill.el --- kill & mark things easily       -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2015  Free Software Foundation, Inc.
+;; Copyright (C) 2013-2018  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <sdl.web@gmail.com>
 ;; Version: 0.9.4
@@ -119,6 +119,7 @@ deprecated."
     (define-key map "-" 'easy-kill-shrink)
     (define-key map "+" 'easy-kill-expand)
     (define-key map "=" 'easy-kill-expand)
+    (define-key map " " 'easy-kill-cycle)
     (define-key map "@" 'easy-kill-append)
     ;; Note: didn't pick C-h because it is a very useful prefix key.
     (define-key map "?" 'easy-kill-help)
@@ -380,6 +381,23 @@ candidate property instead."
   (interactive)
   (easy-kill-thing nil '+))
 
+(defun easy-kill-cycle (&optional thing)
+  "Cycle through things in `easy-kill-alist'."
+  (interactive)
+  (let ((next (easy-kill-cycle-next (or thing (easy-kill-get thing)))))
+    (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)
+  (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))))))
+
 (defun easy-kill-digit-argument (n)
   "Expand selection by N number of things.
 If N is 0 shrink the selection to the initial size before any



reply via email to

[Prev in Thread] Current Thread [Next in Thread]