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

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

[elpa] 01/16: New command easy-kill-help


From: Leo Liu
Subject: [elpa] 01/16: New command easy-kill-help
Date: Tue, 22 Apr 2014 00:33:37 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit dcf715a007a8b04c46c40b7d55016621f3e9422c
Author: Leo Liu <address@hidden>
Date:   Sun Apr 13 17:24:00 2014 +0800

    New command easy-kill-help
---
 README.rst   |    6 ++++++
 easy-kill.el |   57 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/README.rst b/README.rst
index ef660aa..bccccbb 100644
--- a/README.rst
+++ b/README.rst
@@ -37,6 +37,7 @@ The following keys modify the selection:
 #. ``+``, ``-`` and ``0..9``: expand/shrink selection
 #. ``C-SPC``: turn selection into an active region
 #. ``C-g``: abort
+#. ``?``: help
 
 For example, ``M-w w`` saves current word, repeat ``w`` to expand the
 kill to include the next word. ``5`` to include the next 5 words etc.
@@ -86,6 +87,11 @@ convention, or by defining new functions named like
 NEWS
 ~~~~
 
+0.9.3
++++++
+
+#. Key ``?`` in ``easy-kill`` or ``easy-mark`` prints help info.
+
 0.9.2
 +++++
 
diff --git a/easy-kill.el b/easy-kill.el
index 8195bfc..91a1a21 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2013-2014  Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <address@hidden>
-;; Version: 0.9.2
+;; Version: 0.9.3
 ;; Package-Requires: ((emacs "24") (cl-lib "0.5"))
 ;; Keywords: killing, convenience
 ;; Created: 2013-08-12
@@ -113,6 +113,8 @@ deprecated."
     (define-key map "+" 'easy-kill-expand)
     (define-key map "=" 'easy-kill-expand)
     (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)
     (define-key map [remap set-mark-command] 'easy-kill-mark-region)
     (define-key map [remap kill-region] 'easy-kill-region)
     (define-key map [remap keyboard-quit] 'easy-kill-abort)
@@ -121,16 +123,6 @@ deprecated."
           (number-sequence 0 9))
     map))
 
-(defun easy-kill-map ()
-  "Build the keymap according to `easy-kill-alist'."
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map easy-kill-base-map)
-    (mapc (lambda (c)
-            ;; (define-key map (vector meta-prefix-char c) 'easy-kill-select)
-            (define-key map (char-to-string c) 'easy-kill-thing))
-          (mapcar 'car easy-kill-alist))
-    map))
-
 (defvar easy-kill-inhibit-message nil)
 
 (defun easy-kill-echo (format-string &rest args)
@@ -168,6 +160,48 @@ The value is the function's symbol if non-nil."
        (not (equal text ""))
        (funcall interprogram-cut-function text)))
 
+(defun easy-kill-map ()
+  "Build the keymap according to `easy-kill-alist'."
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map easy-kill-base-map)
+    (mapc (lambda (c)
+            ;; (define-key map (vector meta-prefix-char c) 'easy-kill-select)
+            (define-key map (char-to-string c) 'easy-kill-thing))
+          (mapcar 'car easy-kill-alist))
+    map))
+
+(defun easy-kill--fmt (x y z)
+  (cl-etypecase x
+    (character (easy-kill--fmt
+                (single-key-description x)
+                (symbol-name y)
+                (let ((print-escape-newlines t))
+                  (prin1-to-string z))))
+    (string (with-output-to-string
+              (princ x)
+              (princ (make-string (- 16 (length x)) ?\s))
+              (princ y)
+              (princ (make-string (- 16 (length y)) ?\s))
+              (princ z)))))
+
+(defun easy-kill-help ()
+  (interactive)
+  (help-setup-xref '(easy-kill-help) (called-interactively-p 'any))
+  (with-help-window (help-buffer)
+    (princ (concat (make-string 15 ?=) " "))
+    (princ "Easy Kill/Mark Key Bindings ")
+    (princ (concat (make-string 15 ?=) "\n\n"))
+    (princ (easy-kill--fmt "Key" "Thing" "Separator"))
+    (princ "\n")
+    (princ (easy-kill--fmt "---" "-----" "---------"))
+    (princ "\n\n")
+    (princ (mapconcat (lambda (x)
+                        (pcase x
+                          (`(,c ,thing ,sep) (easy-kill--fmt c thing sep))))
+                      easy-kill-alist "\n"))
+    (princ "\n")
+    (princ (substitute-command-keys "\\{easy-kill-base-map}"))))
+
 (defvar easy-kill-candidate nil)
 (defvar easy-kill-append nil)
 (defvar easy-kill-mark nil)
@@ -483,6 +517,7 @@ Temporally activate additional key bindings as follows:
   0..9    => expand selection by that number;
   +,=/-   => expand or shrink selection;
   @       => append selection to previous kill;
+  ?       => help;
   C-w     => kill selection;
   C-SPC   => turn selection into an active region;
   C-g     => abort;



reply via email to

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