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

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

[elpa] externals/consult 5a02663b46: consult--left-truncate-file: Preser


From: ELPA Syncer
Subject: [elpa] externals/consult 5a02663b46: consult--left-truncate-file: Preserve remote prefix
Date: Mon, 30 Sep 2024 06:57:41 -0400 (EDT)

branch: externals/consult
commit 5a02663b46f3ecc3d2f853c2c73923e35a288925
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    consult--left-truncate-file: Preserve remote prefix
---
 consult.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/consult.el b/consult.el
index 540561e0f9..05ef01c477 100644
--- a/consult.el
+++ b/consult.el
@@ -751,11 +751,15 @@ network file systems."
 (defun consult--left-truncate-file (file)
   "Return abbreviated file name of FILE for use in `completing-read' prompt."
   (save-match-data
-    (setq file (directory-file-name (abbreviate-file-name file)))
-    (if (and (string-match "/\\([^/]+\\)/\\([^/]+\\)\\'" file)
-             (< (- (match-end 0) (match-beginning 0) -3) (length file)))
-        (format "…/%s/%s" (match-string 1 file) (match-string 2 file))
-      file)))
+    (let ((file (directory-file-name (abbreviate-file-name file)))
+          (prefix nil))
+      (when (string-match "\\`/\\([^/|:]+:\\)" file)
+        (setq prefix (propertize (match-string 1 file) 'face 'error)
+              file (substring file (match-end 0))))
+      (when (and (string-match "/\\([^/]+\\)/\\([^/]+\\)\\'" file)
+                 (< (- (match-end 0) (match-beginning 0) -3) (length file)))
+        (setq file (format "…/%s/%s" (match-string 1 file) (match-string 2 
file))))
+      (concat prefix file))))
 
 (defun consult--directory-prompt (prompt dir)
   "Return prompt, paths and default directory.



reply via email to

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