4

In the compilation environment in emacs (M-x compile), whenever there is a path to file (ex.: ../src/code.cpp:21:3: warning: comparison between...) it highlights the path and make it clickable. When clicked, it opens the file in the corresponding line.

I wanted to enable a similar feature in eshell. So that it would highlight and make clickable everything that looks like a file path. How to do that? Is there any script available for that?

[Edit] - clarifications.

  • Do you mean when you compile something from eshell? Or just generally "everything that looks like it might be a file path should be processed" ? – phils May 9 '17 at 12:10
  • @phils I mean generally, everything that looks like it might a file path. – rph May 9 '17 at 12:11
  • What sort of constraints would you apply to that? Because every single word of output could be a filename, and testing to see if each word actually is a filename would seem to be awfully inefficient. – phils May 9 '17 at 12:13
  • @phils I hear what you say. Is there a way to test only those currently visible in the screen? This would reduce the number of words to be processed, and should be very handy already! – rph May 9 '17 at 12:17
  • You'd perhaps use after-change-functions, checking against the visible bounds of the window, and then searching and applying text properties as you go. And you could detect what the directory would be for each potential file, and check against a hash of the directory contents, so performance-wise it might work out acceptably. I can't point you at any existing implementation though (and I don't particularly want to figure out how to do this), but maybe others can help more. – phils May 9 '17 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.