From: Stephen Eglen <sje30@cam.ac.uk>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stephen Eglen <sje30@cam.ac.uk>, emacs-devel@gnu.org
Subject: Re: Emacs support for --hyperlink in ls?
Date: Tue, 03 May 2022 21:38:47 +0100 [thread overview]
Message-ID: <87zgjy9w5z.fsf@cam.ac.uk> (raw)
In-Reply-To: <83mtfy4znf.fsf@gnu.org>
> comint.el already supports OSC 8, since Emacs 28.
Thank you! I should have checked NEWS closer.
I have added this:
(add-to-list 'comint-output-filter-functions 'comint-osc-process-output)
and confirm that in *shell* the filenames are now hyperlinks.
However, at least on my system, I find the following problem that I
think is caused by ls, rather than Emacs. e.g.
$ ls --hyperlink /etc/anacrontab
generates the following filename (after removing the markup)
file://light/etc/anacrontab
where 'light' is the name of my laptop (running arch linux).
browse-url-xdg-open is my browser-function, and
$ xdg-open file://light/etc/anacrontab
generates the error:
xdg-open: file 'file://light/etc/anacrontab' does not exist
I have made a temporary workaround by adapting the following function to
remove the hostname if it matches (system-name) which seems to solve the
problem for me in initial testing, so that e.g. the URL becomes
file:///etc/anacrontab
(defun comint-osc-hyperlink-handler (_ text)
"Create a hyperlink from an OSC 8 escape sequence.
This function is intended to be included as an entry of
`comint-osc-handlers'."
(when comint-osc-hyperlink--state
(let ((start (car comint-osc-hyperlink--state))
(url (cdr comint-osc-hyperlink--state)))
(make-text-button start (point)
'type 'comint-osc-hyperlink
'browse-url-data url)))
(setq comint-osc-hyperlink--state
(and (string-match ";\\(.+\\)" text)
(cons (point-marker) (match-string-no-properties 1 text))))
(let* ( (url (url-generic-parse-url (cdr comint-osc-hyperlink--state)))
(host (url-host url)))
(when (equal (system-name) host)
(setq comint-osc-hyperlink--state
(cons
(car comint-osc-hyperlink--state)
(concat "file://" (url-filename url)))))))
However, is this the correct approach? (I note that a similar issue was
filed for kitty terminal, which also resulted in kitty being patched in
a similar fashion: https://github.com/kovidgoyal/kitty/issues/2970 so at
least it is not just my system. The 'foot' terminal also does not parse
urls with hostname that is not FQDN.)
Stephen
next prev parent reply other threads:[~2022-05-03 20:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-03 11:08 Emacs support for --hyperlink in ls? Stephen Eglen
2022-05-03 11:35 ` Eli Zaretskii
2022-05-03 20:38 ` Stephen Eglen [this message]
2022-05-04 5:48 ` Eli Zaretskii
2022-05-06 12:17 ` Augusto Stoffel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgjy9w5z.fsf@cam.ac.uk \
--to=sje30@cam.ac.uk \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.