From 850aca9d754bdda60599b0b5ca851005e76b6661 Mon Sep 17 00:00:00 2001 From: Nick OBrien Date: Thu, 28 Mar 2024 22:45:26 -0500 Subject: [PATCH] Highlight entire tramp file names instead of just base name When in a tramp default-directory like "/ssh:user@host:dir", acting on a file target named "path/to/file.ext" would previously only highlight "file". With this change, all of the path is highlighted. Ideally, all "magic" file names should be handled, but tramp's file-local-name handler doesn't keep "path/to/file.ext" intact and can't be used to match against tap-file. --- embark.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/embark.el b/embark.el index d00968d..e312960 100644 --- a/embark.el +++ b/embark.el @@ -723,6 +723,14 @@ This function is meant to be added to `minibuffer-setup-hook'." ;; thingatpt bounds, which might be a little off ;; adjust bounds if thingatpt gobbled punctuation around file (when (or (string-match (regexp-quote file) tap-file) + ;; If the file is a tramp file name, try matching with the local + ;; part. + (if (boundp 'tramp-file-name-structure) + (if-let (((string-match + (nth 0 tramp-file-name-structure) file)) + (local-file + (match-string (nth 4 tramp-file-name-structure) file))) + (string-match (regexp-quote local-file) tap-file))) (string-match (regexp-quote (file-name-base file)) tap-file)) (setq bounds (cons (+ (car bounds) (match-beginning 0)) (- (cdr bounds) (- (length tap-file)