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

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

[elpa] externals/kubed fe844378f0 53/70: ; Add 'kubed-list-copy-as-kill'


From: ELPA Syncer
Subject: [elpa] externals/kubed fe844378f0 53/70: ; Add 'kubed-list-copy-as-kill' to context menus
Date: Tue, 6 Aug 2024 06:58:40 -0400 (EDT)

branch: externals/kubed
commit fe844378f0d6c202a663300660d27e46e83c8bc1
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ; 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 c2d4586169..110475dee7 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 c11768a014..9b1e33c45f 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



reply via email to

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