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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ All notable changes to this project will be documented in this file.
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.
- File link detection skips paths starting with `/\`, such as the regex
`/\r/g`. On Windows such text names a network share, and looking up the
host froze Emacs for seconds.

## [0.68.0] — 2026-11-30

Expand Down
5 changes: 3 additions & 2 deletions lisp/ghostel-links.el
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,9 @@ Return the \(BEGIN . END) covered, the bounds widened to whole logical lines."
(fragments (ghostel--wrap-fragments beg mend)))
;; `//' starts a comment or the host half of a URL, not a file;
;; this alone keeps a URL's `//host/path' out of the file pass.
;; On Windows it names a share whose lookup can hang Emacs.
(unless (string-prefix-p "//" path)
;; On Windows it names a share whose lookup can hang Emacs, and
;; so does `/\', as in the regex `/\r/g'.
(unless (string-match-p "\\`/[/\\]" path)
(if (ghostel--skip-match-p fragments raw active-bounds)
;; Whatever is there stays; it must not count as stranded.
(push (cons beg mend) matched)
Expand Down
18 changes: 18 additions & 0 deletions test/ghostel-links-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,24 @@ A single leading slash and relative paths still link."
(mapcar #'cadr (ghostel-test--link-runs))))
(ignore dir))))

(ert-deftest ghostel-test-detect-skips-slash-backslash-paths ()
"A `/\\' candidate, as in the regex `/\\r/g', is never checked or linked.
On Windows it expands to a `//' network share."
(ghostel-test--with-link-fixture (dir file)
(with-temp-buffer
(insert "s.replace(/\\r/g, '') x = /\\d+/.test(y) " file "\n")
(goto-char (point-max))
(let ((checked nil))
(cl-letf* ((exists (symbol-function 'file-exists-p))
((symbol-function 'file-exists-p)
(lambda (f) (push f checked) (funcall exists f))))
(ghostel--detect-urls))
(should-not (seq-find (lambda (f) (string-match-p "\\`/[/\\]" f))
checked)))
(should (equal (list (concat "fileref:" file))
(mapcar #'cadr (ghostel-test--link-runs))))
(ignore dir))))

(ert-deftest ghostel-test-detect-replaces-stale-url-link-in-one-scan ()
"A leftover URL link over what is now a path becomes the path link.
One scan is enough: the file pass must not treat a URL link no URL
Expand Down
Loading