]> git.eshelyaron.com Git - emacs.git/commitdiff
Add remote file functions to shortdoc
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 3 Jun 2022 17:54:31 +0000 (19:54 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 3 Jun 2022 17:54:31 +0000 (19:54 +0200)
* lisp/net/tramp-integration.el (shortdoc-add-function)
(shortdoc--groups): Declare.
(shortdoc): Configure shortdoc.el to recognize file name functions
for remote access.

lisp/net/tramp-integration.el

index b7f82770c40547b91404f33ce92ae5956cab5b85..5e51074c4944f064aeffc85e7ddd00cbee843cee 100644 (file)
@@ -39,6 +39,7 @@
 (declare-function info-lookup->topic-value "info-look")
 (declare-function info-lookup-maybe-add-help "info-look")
 (declare-function recentf-cleanup "recentf")
+(declare-function shortdoc-add-function "shortdoc")
 (declare-function tramp-dissect-file-name "tramp")
 (declare-function tramp-file-name-equal-p "tramp")
 (declare-function tramp-tramp-file-p "tramp")
@@ -49,6 +50,7 @@
 (defvar info-lookup-alist)
 (defvar ivy-completing-read-handlers-alist)
 (defvar recentf-exclude)
+(defvar shortdoc--groups)
 (defvar tramp-current-connection)
 (defvar tramp-postfix-host-format)
 (defvar tramp-use-ssh-controlmaster-options)
@@ -257,6 +259,33 @@ NAME must be equal to `tramp-current-connection'."
                  (delete (info-lookup->mode-cache 'symbol ',mode)
                          (info-lookup->topic-cache 'symbol))))))))
 
+;;; 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))
+                 (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:
 
 ;; Compilation processes use `accept-process-output' such a way that