emacs-diffs
[Top][All Lists]
Advanced

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

emacs-30 3817355aed5: Add sanity check when adding Tramp functions to sh


From: Michael Albinus
Subject: emacs-30 3817355aed5: Add sanity check when adding Tramp functions to shortdoc
Date: Mon, 5 Aug 2024 14:19:45 -0400 (EDT)

branch: emacs-30
commit 3817355aed503e79c03bca5d203bd73716d10d9e
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Add sanity check when adding Tramp functions to shortdoc
    
    * lisp/net/tramp-integration.el (shortdoc): Check, that Tramp
    isn't disabled.
---
 lisp/net/tramp-integration.el | 58 ++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index 56deaf9066b..6b28ddb7472 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -275,34 +275,36 @@ NAME must be equal to `tramp-current-connection'."
 ;;; Integration of shortdoc.el:
 
 (with-eval-after-load 'shortdoc
-  (dolist (elem `((file-remote-p
-                  :eval (file-remote-p "/ssh:user@host:/tmp/foo")
-                  :eval (file-remote-p "/ssh:user@host:/tmp/foo" 'method)
-                  :eval (file-remote-p "/ssh:user@[::1]#1234:/tmp/foo" 'host)
-                  ;; We don't want to see the text properties.
-                  :no-eval (file-remote-p "/sudo::/tmp/foo" 'user)
-                  :result ,(substring-no-properties
-                            (file-remote-p "/sudo::/tmp/foo" 'user)))
-                 (file-local-name
-                  :eval (file-local-name "/ssh:user@host:/tmp/foo"))
-                 (file-local-copy
-                  :no-eval (file-local-copy "/ssh:user@host:/tmp/foo")
-                  :eg-result "/tmp/tramp.8ihLbO"
-                  :eval (file-local-copy "/tmp/foo"))))
-    (unless (assoc (car elem)
-                  (member "Remote Files" (assq 'file shortdoc--groups)))
-      (shortdoc-add-function 'file "Remote Files" elem)))
-
-  (add-hook
-   'tramp-integration-unload-hook
-   (lambda ()
-     (let ((glist (assq 'file shortdoc--groups)))
-       (while (and (consp glist)
-                   (not (and (stringp (cadr glist))
-                             (string-equal (cadr glist) "Remote Files"))))
-         (setq glist (cdr glist)))
-       (when (consp glist)
-         (setcdr glist nil))))))
+  ;; Some packages deactivate Tramp.  They don't deserve a shortdoc entry then.
+  (when (file-remote-p "/ssh:user@host:/tmp/foo")
+    (dolist (elem `((file-remote-p
+                    :eval (file-remote-p "/ssh:user@host:/tmp/foo")
+                    :eval (file-remote-p "/ssh:user@host:/tmp/foo" 'method)
+                    :eval (file-remote-p "/ssh:user@[::1]#1234:/tmp/foo" 'host)
+                    ;; We don't want to see the text properties.
+                    :no-eval (file-remote-p "/sudo::/tmp/foo" 'user)
+                    :result ,(substring-no-properties
+                              (file-remote-p "/sudo::/tmp/foo" 'user)))
+                   (file-local-name
+                    :eval (file-local-name "/ssh:user@host:/tmp/foo"))
+                   (file-local-copy
+                    :no-eval (file-local-copy "/ssh:user@host:/tmp/foo")
+                    :eg-result "/tmp/tramp.8ihLbO"
+                    :eval (file-local-copy "/tmp/foo"))))
+      (unless (assoc (car elem)
+                    (member "Remote Files" (assq 'file shortdoc--groups)))
+       (shortdoc-add-function 'file "Remote Files" elem)))
+
+    (add-hook
+     'tramp-integration-unload-hook
+     (lambda ()
+       (let ((glist (assq 'file shortdoc--groups)))
+        (while (and (consp glist)
+                     (not (and (stringp (cadr glist))
+                               (string-equal (cadr glist) "Remote Files"))))
+           (setq glist (cdr glist)))
+        (when (consp glist)
+           (setcdr glist nil)))))))
 
 ;;; Integration of compile.el:
 



reply via email to

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