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

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

[nongnu] elpa/helm fc92f652ec 2/3: Add new command to complete tramp met


From: ELPA Syncer
Subject: [nongnu] elpa/helm fc92f652ec 2/3: Add new command to complete tramp methods from HFF
Date: Sat, 11 Jun 2022 04:58:33 -0400 (EDT)

branch: elpa/helm
commit fc92f652ecbecf4208bbfc0cbd4204a50aa7124a
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Add new command to complete tramp methods from HFF
---
 helm-files.el | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/helm-files.el b/helm-files.el
index d7acf0c3e0..a391e71be4 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -717,6 +717,7 @@ It is generally \"~/.local/share/Trash\"."
     (define-key map (kbd "M-+")           
'helm-ff-increase-image-size-persistent)
     (define-key map (kbd "M--")           
'helm-ff-decrease-image-size-persistent)
     (define-key map (kbd "C-l")           'helm-find-files-up-one-level)
+    (define-key map (kbd "C-:")           'helm-ff-complete-tramp-methods)
     (define-key map (kbd "C-_")           'helm-ff-undo)
     (define-key map (kbd "C-r")           'helm-find-files-down-last-level)
     (define-key map (kbd "C-c r")         'helm-ff-run-find-file-as-root)
@@ -745,6 +746,7 @@ It is generally \"~/.local/share/Trash\"."
     (define-key map (kbd "C-]")           'helm-ff-run-toggle-basename)
     (define-key map (kbd "C-.")           'helm-find-files-up-one-level)
     (define-key map (kbd "C-l")           'helm-find-files-up-one-level)
+    (define-key map (kbd "C-:")           'helm-ff-complete-tramp-methods)
     (define-key map (kbd "C-_")           'helm-ff-undo)
     (define-key map (kbd "C-r")           'helm-find-files-down-last-level)
     (define-key map (kbd "C-c h")         'helm-ff-file-name-history)
@@ -3178,6 +3180,36 @@ debugging purpose."
   (cl-loop for m in (helm-ff--get-tramp-methods)
            thereis (string-match (format "\\`\\(/%s:.*[|]\\).*" m) name)))
 
+(defun helm-ff-complete-tramp-methods ()
+  "Completion on tramp methods in a nested helm session."
+  (interactive)
+  (with-helm-alive-p
+    (let* (initial-input
+           (str helm-pattern)
+           (pattern (with-temp-buffer
+                      (insert str)
+                      (let ((end (point)) beg)
+                        (when (re-search-backward "[/|]" nil t)
+                          (setq beg (1+ (point)))
+                          (unless (= beg end)
+                            (setq initial-input
+                                  (buffer-substring beg end))
+                            (delete-region beg end))
+                          (buffer-string)))))
+           (collection (helm-ff--get-tramp-methods))
+           (method (helm-comp-read
+                    "Tramp methods: "
+                    (sort collection #'string<)
+                    :initial-input initial-input
+                    :fc-transformer
+                    (lambda (candidates _source)
+                      (cl-loop for c in candidates
+                               collect (propertize c 'face 'helm-ff-file)))
+                    :allow-nest t
+                    :must-match t)))
+      (helm-set-pattern (concat pattern method ":")))))
+(put 'helm-ff-complete-tramp-methods 'no-helm-mx t)
+
 (defun helm-ff-set-pattern (pattern)
   "Handle tramp filenames in `helm-pattern'."
   (let* ((methods (helm-ff--get-tramp-methods))



reply via email to

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