From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 1/3] emacs: Add "c" key binding to copy a button link. Date: Sun, 09 Nov 2014 11:39:43 +0300 Message-ID: <87h9y8bwds.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnO2L-0002qx-Bm for guix-devel@gnu.org; Sun, 09 Nov 2014 03:40:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnO2C-0007fF-89 for guix-devel@gnu.org; Sun, 09 Nov 2014 03:39:53 -0500 Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]:55215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnO2B-0007es-T4 for guix-devel@gnu.org; Sun, 09 Nov 2014 03:39:44 -0500 Received: by mail-lb0-f170.google.com with SMTP id p9so1295592lbv.1 for ; Sun, 09 Nov 2014 00:39:41 -0800 (PST) Received: from leviafan (128-74-164-65.broadband.corbina.ru. [128.74.164.65]) by mx.google.com with ESMTPSA id s5sm1265547laa.9.2014.11.09.00.39.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Nov 2014 00:39:40 -0800 (PST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain I think it may be useful to copy the current URL or file path by pressing "c". --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-emacs-Add-c-key-binding-to-copy-a-button-link.patch >From c55a306d9a0588b3950e2905fb288200c27faa84 Mon Sep 17 00:00:00 2001 From: Alex Kost 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." ;;; 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 --=-=-=--