Reputation: 3945
If I'm in a term-mode
buffer and there is a file path displayed, how would I go about making the path "clickable", opening the file in a new buffer? It doesn't have to be mouse-clickable, in fact I'd prefer a key binding that works when the point is on the file path. Other than the common case of using ls
, this function could be used when viewing a log file. Some debug info contains the file path and line number. Something like lib/library.rb:34
for example. Ideally, Emacs could open a new buffer and move the cursor to line 34
.
Upvotes: 3
Views: 1363
Reputation: 60014
The short answer is: don't work against Emacs. Let Emacs work for you.
While you can use find-file-at-point
or put together something yourself, you will be much better off running make
, grep
and other stuff which prints "dir/file:pos"
using M-x compile or M-x grep.
If you need to interact with your program which prints "dir/file:pos"
, you can pass a prefix argument to compile
and the compilation buffer will be interactive.
If you have an arbitrary program whose output starts with "dir/file:pos"
, e.g., rails server
, all you need to do is run it as (grep "rails server")
.
Upvotes: 3