From fe844378f0d6c202a663300660d27e46e83c8bc1 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Fri, 2 Aug 2024 19:35:55 +0200 Subject: [PATCH] ; Add 'kubed-list-copy-as-kill' to context menus * kubed.el (kubed-list-copy-as-kill): Fix typo. (kubed-list-context-menu): New function. (kubed-list-mode): Add it to 'context-menu-functions'. * kubed.texi (Browsing Resources): Mention 'kubed-list-copy-as-kill'. --- kubed.el | 15 ++++++++++++--- kubed.texi | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/kubed.el b/kubed.el index c2d4586..110475d 100644 --- a/kubed.el +++ b/kubed.el @@ -369,7 +369,7 @@ to 1." (goto-char next))) (defun kubed-list-copy-as-kill (click) - "Copy name of Kubernetes resource at CLICK to into the kill ring." + "Copy name of Kubernetes resource at CLICK into the kill ring." (interactive (list last-nonmenu-event) kubed-list-mode) (if-let ((ent (tabulated-list-get-entry (mouse-set-point click))) (new (aref ent 0))) @@ -378,6 +378,13 @@ to 1." (message "Copied resource name `%s'" new)) (user-error "No Kubernetes resource at point"))) +(defun kubed-list-context-menu (menu click) + "Extend MENU with common actions on Kubernetes resource at CLICK." + (when (tabulated-list-get-entry (posn-point (event-start click))) + (define-key menu [kubed-list-copy-as-kill] + '(menu-item "Copy name" kubed-list-copy-as-kill))) + menu) + (defvar-keymap kubed-list-mode-map :doc "Common keymap for Kubernetes resource list buffers." "/" #'kubed-list-set-filter @@ -413,11 +420,13 @@ mode as their parent." (save-excursion (goto-char (point-min)) (while (not (eobp)) - (when-let ((mark (alist-get (tabulated-list-get-id) marks nil nil #'equal))) + (when-let ((mark (alist-get (tabulated-list-get-id) + marks nil nil #'equal))) (tabulated-list-put-tag mark)) (forward-line)))))) nil t) - (setq-local truncate-string-ellipsis (propertize ">" 'face 'shadow))) + (setq-local truncate-string-ellipsis (propertize ">" 'face 'shadow)) + (add-hook 'context-menu-functions #'kubed-list-context-menu nil t)) ;;;###autoload (defmacro kubed-define-resource (resource &optional properties &rest commands) diff --git a/kubed.texi b/kubed.texi index c11768a..9b1e33c 100644 --- a/kubed.texi +++ b/kubed.texi @@ -231,6 +231,11 @@ Unmark from resource at point (@code{kubed-list-unmark}). Toggle @code{kubed-all-namespaces-mode}. When enabled, resource lists for namespaced resource types show resources from all namespaces, not just the current namespace. +@kindex w +@findex kubed-list-copy-as-kill +@item w +Copy name of resource at point into the kill ring +(@code{kubed-list-copy-as-kill}). @kindex n @findex next-line @item n -- 2.39.2