[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kubed eaf03ec7e2 09/70: Improve compatibility with Emac
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kubed eaf03ec7e2 09/70: Improve compatibility with Emacs 29 |
Date: |
Tue, 6 Aug 2024 06:58:25 -0400 (EDT) |
branch: externals/kubed
commit eaf03ec7e2e3a757716698bf0ba8b53d903207c7
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Improve compatibility with Emacs 29
* kubed.el (tramp-kubernetes-namespace): Remove declaration.
(kubed--static-if): New macro. Compatibility definition of
'static-if' from Emacs 30.
(kubed-pods-dired, kubed-pods-shell): Do not rely on
explicit Kubernetes namespace in remote file name syntax in
Emacs versions earlier than 31.
(kubed-define-resource): Use 'emacsclient-program-name' only
in Emacs 30 or later.
---
kubed.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 48 insertions(+), 7 deletions(-)
diff --git a/kubed.el b/kubed.el
index 1aabc91b89..487cde8b1c 100644
--- a/kubed.el
+++ b/kubed.el
@@ -502,7 +502,9 @@ Optional argument DEFAULT is the minibuffer default
argument." resource)
`(list (,read-fun "Edit"))))
(unless (bound-and-true-p server-process) (server-start))
(let ((process-environment
- (cons (concat "KUBE_EDITOR=" emacsclient-program-name)
+ (cons ,(if (<= 30 emacs-major-version)
+ '(concat "KUBE_EDITOR=" 'emacsclient-program-name)
+ "KUBE_EDITOR=emacsclient")
process-environment)))
(start-process ,(format "*kubed-%S-edit*" plrl-var) nil
kubed-kubectl-program "edit"
@@ -848,7 +850,19 @@ Optional argument DEFAULT is the minibuffer default
argument." resource)
"E" #',expl-cmd
,@prf-keys))))
-(defvar tramp-kubernetes-namespace)
+(defmacro kubed--static-if (condition then-form &rest else-forms)
+ "A conditional compilation macro.
+Evaluate CONDITION at macro-expansion time. If it is non-nil, expand
+the macro to THEN-FORM. Otherwise expand it to ELSE-FORMS enclosed in a
+‘progn’ form. ELSE-FORMS may be empty.
+
+This is the same as `static-if' from Emacs 30, defined here for
+compatibility with earlier Emacs versions."
+ (declare (indent 2)
+ (debug (sexp sexp &rest sexp)))
+ (if (eval condition lexical-binding)
+ then-form
+ (cons 'progn else-forms)))
;;;###autoload (autoload 'kubed-display-pod "kubed" nil t)
;;;###autoload (autoload 'kubed-edit-pod "kubed" nil t)
@@ -886,12 +900,39 @@ Optional argument DEFAULT is the minibuffer default
argument." resource)
"X" #'kubed-exec
"F" #'kubed-forward-port-to-pod)
(dired "C-d" "Start Dired in home directory of first container of"
- (let ((ns (when k8sns (concat "%" k8sns))))
- (dired (concat "/kubernetes:" pod ns ":"))))
+ ;; Explicit namespace in Kuberenetes remote file names
+ ;; introduced in Emacs 31. See Bug#59797.
+ (kubed--static-if (<= 31 emacs-major-version)
+ (let ((ns (when k8sns (concat "%" k8sns))))
+ (dired (concat "/kubernetes:" pod ns ":")))
+ (when k8sns
+ (if (y-or-n-p
+ (format "Starting Dired in a pod in a different namespace \
+requires Emacs 31 or later.
+You can proceed by first switching your current namespace.
+Switch to namespace `%s' and proceed?" k8sns))
+ (kubed-set-namespace k8sns)
+ (user-error
+ "Cannot start Dired in a pod in different namespace `%s'"
+ k8sns)))
+ (dired (concat "/kubernetes:" pod ":"))))
(shell "s" "Start shell in home directory of first container of"
- (let* ((ns (when k8sns (concat "%" k8sns)))
- (default-directory (concat "/kubernetes:" pod ns ":")))
- (shell (format "*kubed-pod-%s-shell*" pod))))
+ (kubed--static-if (<= 31 emacs-major-version)
+ (let* ((ns (when k8sns (concat "%" k8sns)))
+ (default-directory (concat "/kubernetes:" pod ns ":")))
+ (shell (format "*kubed-pod-%s-shell*" pod)))
+ (when k8sns
+ (if (y-or-n-p
+ (format "Starting Shell in a pod in a different namespace \
+requires Emacs 31 or later.
+You can proceed by first switching your current namespace.
+Switch to namespace `%s' and proceed?" k8sns))
+ (kubed-set-namespace k8sns)
+ (user-error
+ "Cannot start Dired in a pod in different namespace `%s'"
+ k8sns)))
+ (let* ((default-directory (concat "/kubernetes:" pod ":")))
+ (shell (format "*kubed-pod-%s-shell*" pod)))))
(attach "a" "Attach to remote process running on"
(kubed-attach pod (kubed-read-container pod "Container" t k8sns)
k8sns t t))
- [elpa] branch externals/kubed created (now f65ee0e44a), ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 22ba7fb525 03/70: ; * kubed.texi (Getting Started): Fix itemization, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 4725515591 05/70: ; Update .gitignore, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed d1efd91fe8 08/70: * kubed.el (deployment): Add useful resource properties, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed c5c03e9024 07/70: * kubed.el (service): Add useful resource properties, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed eaf03ec7e2 09/70: Improve compatibility with Emacs 29,
ELPA Syncer <=
- [elpa] externals/kubed d7a4f0d5ab 01/70: Initial commit, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 524aebf3f6 06/70: ; * kubed.el: Silence warning about 'cobra-read-command-line'., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 6996279938 11/70: Add context menus to resource list buffers, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed aee9cddd59 13/70: ; Fix 'kubed-kubectl-command' error when 'transient' is not loaded, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 324fc95325 10/70: ; Don't generate extra nils for non-namespaced resources, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 03c0121c64 18/70: Add argument SILENT to 'kubed-update-RESOURCEs' commands, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed e2699427a9 20/70: New command 'kubed-cronjobs-toggle-suspension', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed adbbefb6c2 21/70: ; README.md: Add figure showing help for resource fields, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed e948eb9335 04/70: ; * kubed.texi (Usage): Populate with a few words., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 38a8f984fb 15/70: ; Teach Imenu about 'kubed-define-resource', ELPA Syncer, 2024/08/06