Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
### Fixed
- evil-ghostel: the editing operators and insert-state Ctrl keys drive the
shell in a bridged terminal, such as a rexel or ghostel-tmux buffer.
- A `file://` link without a host, or with `localhost`, opens on the remote
host in a terminal whose `default-directory` is remote.

## [0.68.0] — 2026-11-30

Expand Down
14 changes: 9 additions & 5 deletions lisp/ghostel-links.el
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ An END-LINE also marks the lines from LINE to END-LINE as the region."

(defun ghostel--open-link (url)
"Open URL by scheme.
`fileref:' and `file://' open in another window, a fileref at its line
and column, a file URI at its `#23', `#L23', `#L23C5' or `#L23-L42'
fragment, marking a line range. A file URI opens even when the file does not
exist. A bare path[:LINE[:COL]] resolves against `default-directory'.
`fileref:' and `file://' open in another window, a fileref at its line and
column, a file URI at its `#23', `#L23', `#L23C5' or `#L23-L42' fragment,
marking a line range. A file URI opens even when the file does not exist;
without a host or with `localhost', it opens on the host of `default-directory'.
A bare path[:LINE[:COL]] resolves against `default-directory'.
Anything else goes to `browse-url'."
(when (stringp url)
(cond
Expand All @@ -194,11 +195,14 @@ Anything else goes to `browse-url'."
(line (match-string 3 url))
(col (match-string 4 url))
(end-line (match-string 5 url))
(file (ghostel--file-uri-decode path)))
(file (ghostel--file-uri-decode path))
(remote (file-remote-p default-directory)))
(when file
(find-file-other-window
(cond ((not (ghostel-local-host-p host))
(ghostel--tramp-path host file))
((and remote (member host '("" "localhost")))
(concat remote file))
((eq system-type 'windows-nt)
(ghostel--windows-local-path file))
(t file)))
Expand Down
9 changes: 9 additions & 0 deletions test/ghostel-links-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,15 @@ row. Navigation should land on the link only once, not on each chunk."
(gnu/linux "/tmp/" "file://Remote/tmp/x" "/ssh:remote:/tmp/x")
(gnu/linux "/ssh:user@remote:/home/" "file://remote/tmp/x"
"/ssh:user@remote:/tmp/x")
;; No host, or localhost, is the terminal's host.
(gnu/linux "/ssh:user@remote:/home/" "file:///tmp/x#L3"
"/ssh:user@remote:/tmp/x")
(gnu/linux "/ssh:user@remote:/home/" "file://localhost/tmp/x"
"/ssh:user@remote:/tmp/x")
(gnu/linux "/ssh:user@remote:/home/"
,(concat "file://" (system-name) "/tmp/x") "/tmp/x")
(windows-nt "/ssh:user@remote:/home/" "file:///tmp/x"
"/ssh:user@remote:/tmp/x")
(windows-nt "/tmp/" "file:///C:/a%20b.txt" "C:/a b.txt")
(windows-nt "/tmp/" "file://localhost/d:\\x.txt"
"d:\\x.txt")))
Expand Down
Loading