* [PATCH 1/3] emacs: Add "c" key binding to copy a button link.
@ 2014-11-09 8:39 Alex Kost
2014-11-09 17:40 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Alex Kost @ 2014-11-09 8:39 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 80 bytes --]
I think it may be useful to copy the current URL or file path by
pressing "c".
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-Add-c-key-binding-to-copy-a-button-link.patch --]
[-- Type: text/x-diff, Size: 2515 bytes --]
From c55a306d9a0588b3950e2905fb288200c27faa84 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Sat, 8 Nov 2014 20:13:32 +0300
Subject: [PATCH 1/3] 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'.
---
doc/emacs.texi | 6 ++++++
emacs/guix-info.el | 16 ++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/doc/emacs.texi b/doc/emacs.texi
index 89e2570..ad2dcd8 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -290,6 +290,9 @@ emacs, The GNU Emacs Manual}) which can be used to:
@end itemize
+It is also possible to copy a button label (a link to an URL or a file)
+by pressing @kbd{c} on a button.
+
@node Emacs Configuration
@subsection Configuration
@@ -397,6 +400,9 @@ Keymap with specific keys for ``output-info'' buffers.
@item guix-generation-info-mode-map
Keymap with specific keys for ``generation-info'' buffers.
+@item guix-info-button-map
+Keymap with keys available when a point is placed on a button.
+
@end table
@node Emacs Appearance
diff --git a/emacs/guix-info.el b/emacs/guix-info.el
index 88363e5..edb4450 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."
\f
;;; 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.
--
2.1.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] emacs: Add "c" key binding to copy a button link.
2014-11-09 8:39 [PATCH 1/3] emacs: Add "c" key binding to copy a button link Alex Kost
@ 2014-11-09 17:40 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2014-11-09 17:40 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
Alex Kost <alezost@gmail.com> skribis:
> I think it may be useful to copy the current URL or file path by
> pressing "c".
>
>
> From c55a306d9a0588b3950e2905fb288200c27faa84 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Sat, 8 Nov 2014 20:13:32 +0300
> Subject: [PATCH 1/3] 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'.
Sure, please push, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-09 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-09 8:39 [PATCH 1/3] emacs: Add "c" key binding to copy a button link Alex Kost
2014-11-09 17:40 ` Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.