From b7ce95f056940ac39eaa31f06749934ca75c366e Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Thu, 16 Jun 2022 21:42:56 -0400 Subject: [ivy] el-patch to allow for TRAMP aliases --- lisp/quality-of-life.el | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lisp/quality-of-life.el b/lisp/quality-of-life.el index 09bba46..8514f55 100644 --- a/lisp/quality-of-life.el +++ b/lisp/quality-of-life.el @@ -31,7 +31,34 @@ ;; If I'm typing a file name with capitalized letters, I may be holding shift ;; when I press space. This is a pain in the ass, and I don't use the feature ;; anyway, so I unbind it. - (bind-key "S-SPC" nil ivy-minibuffer-map)) + (bind-key "S-SPC" nil ivy-minibuffer-map) + + :config/el-patch + (defun ivy-magic-read-file-env () + "If reading filename, jump to environment variable location." + (interactive) + (if (and ivy--directory + (equal ivy-text "")) + (let* ((cands (cl-loop for pair in process-environment + for (var val) = (split-string pair "=" t) + if (and val (not (equal "" val))) + if (or + ;; Don't `file-exists-p' on TRAMP stuff + (el-patch-add (string-suffix-p ":/" val)) + (file-exists-p + (if (file-name-absolute-p val) + val + (setq val + (expand-file-name val ivy--directory))))) + collect (cons var val))) + (enable-recursive-minibuffers t) + (x (ivy-read "Env: " cands)) + (path (cdr (assoc x cands)))) + (insert (if (file-accessible-directory-p path) + (file-name-as-directory path) + path)) + (ivy--cd-maybe)) + (insert last-input-event)))) ;; `counsel' is a nice Ivy-based frontend for a couple of interactive commands. -- cgit v1.3