Skip to content

Commit

Permalink
Highlight entire tramp file names instead of just base name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nick4f42 committed Jul 4, 2024
1 parent 9c166c4 commit 850aca9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions embark.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 850aca9

Please sign in to comment.