emacs-libvterm icon indicating copy to clipboard operation
emacs-libvterm copied to clipboard

How to click and open files (or urls) in vterm?

Open folke opened this issue 5 years ago • 8 comments

Is there any way to make links in vterm clickable?

Suppose I run a linter and see some errors, I would like to ctrl-click or press RET in normal mode, on the file links to open them in a new buffer.

How can I accomplish this?

image

folke avatar Oct 07 '20 07:10 folke

Does ffap work?

jixiuf avatar Oct 07 '20 08:10 jixiuf

Tried that, but it doesn't work. I'm assuming the ansi control characters mess it up.

folke avatar Oct 07 '20 09:10 folke

I use browse-url for that:

      (defun sbozzolo/browse-url (url)
        "Browse url starting with what is at the point"
        (interactive (list
                      (read-string (format "URL (%s): " (thing-at-point 'url))
                                   (thing-at-point 'url) nil (thing-at-point 'url))))
        (browse-url url))

But I agree, it would be nice to be able to just click on the link.

Sbozzolo avatar Oct 07 '20 13:10 Sbozzolo

@Sbozzolo thank you for the suggestion, but that also doesn't seem to work.

The ansi color sequences are messing up with the file detection regex.

When I run npm run lint --no-color, then ffap does work, but then of course I don't have any colors in the output :)

I'm fairly new to Elisp, but will see if I can find a way to get the vterm buffer; strip all ansi control characters somehow; and then run ffap-menu on the result.

I understand this is out of scope for libvterm, so feel free to close this issue.

folke avatar Oct 08 '20 05:10 folke

I forgot to mention that I run the command in vterm-copy-mode. Can you try with that?

Sbozzolo avatar Oct 08 '20 14:10 Sbozzolo

How about using goto-address-mode?

I just enabled it myself and the first impression is good.

Edit: For URLs at least... Not for files.

arnested avatar Dec 30 '20 11:12 arnested

I am searching a solution on this issue as well, @folke have you found a workaround?

fabriziosestito avatar Mar 21 '21 15:03 fabriziosestito

ffap kind of works, but it doesn't work if a file name wraps. Is there a way to detect line continuation in vterm? i.e. differentiate it from an actual newline in the terminal?

aaronjensen avatar Apr 11 '22 06:04 aaronjensen