summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorAlex Kost <alezost@gmail.com>2014-11-08 20:13:32 +0300
committerAlex Kost <alezost@gmail.com>2014-11-10 16:13:40 +0300
commit56149217548cb2b31c0075ffe4adc89ce0362a12 (patch)
tree095172ebae12dbdaea003b35919e70e4d7378a30 /emacs
parent054a3921f09e6670522030829d6367cb1275ba7a (diff)
downloadpatches-56149217548cb2b31c0075ffe4adc89ce0362a12.tar
patches-56149217548cb2b31c0075ffe4adc89ce0362a12.tar.gz
emacs: Add "c" key binding to copy a button link.
* emacs/guix-info.el (guix-info-button-map): New variable. (guix-info-button-copy-label): New procedure. * doc/emacs.texi (Emacs Info buffer): Mention a "c" key binding. (Emacs Keymaps): Add 'guix-info-button-map'.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/guix-info.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 88363e5f24..edb44506ea 100644
--- a/emacs/guix-info.el
+++ b/emacs/guix-info.el
@@ -313,7 +313,15 @@ VAL is a list, call the function on each element of this list."
;;; Buttons
+(defvar guix-info-button-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map button-map)
+ (define-key map (kbd "c") 'guix-info-button-copy-label)
+ map)
+ "Keymap for buttons in info buffers.")
+
(define-button-type 'guix
+ 'keymap guix-info-button-map
'follow-link t)
(define-button-type 'guix-action
@@ -350,6 +358,14 @@ VAL is a list, call the function on each element of this list."
(guix-get-show-entries guix-profile 'info guix-package-info-type
'name (button-label btn))))
+(defun guix-info-button-copy-label (&optional pos)
+ "Copy a label of the button at POS into kill ring.
+If POS is nil, use the current point position."
+ (interactive)
+ (let ((button (button-at (or pos (point)))))
+ (when button
+ (kill-new (button-label button)))))
+
(defun guix-info-insert-action-button (label action &optional message
&rest properties)
"Make action button with LABEL and insert it at point.