0

Running the command org-open-at-point on an external link such as

[[./file.txt::foo][Link]]

causes the file file.txt to be opened in a separate buffer and the cursor to be placed on the first occurrence of the string "foo", if such a search is successful.

Unfortunately the same principle does not apply for a web link such as

[[http://site.com::foo][Link]]

as the external browser is fed the whole text of the link, in this case http://site.com::foo, doing no a posteriori search.

Is there a way to create a web link in an org-mode file which would cause the browser to load a page and then search for a text in it?

1

I think this feature is not about Org. The first example works because the link opens in emacs, and emacs supports search. You can also open a PDF in an external app and jump to a page because the apps support opening on a page. Browsers generally don't support the behavior you described.

If you can script this behavior from outside of Emacs, for example with apple script or a shell script, then you could have a link open that script with the URL and the keyboard.

3
  • Thanks very much for your answer. I am not sure how to write a shell script that will do what you say so I'd really appreciate some hints or reference to manuals. I do knw how to write a shell script, but my main dark spot is how to communicate with the browser via a script. One or two lines exemplifying this behavour would also be greatly appreciated! – Ruy Jan 30 at 22:32
  • It depends on your OS and browser. On Mac, you'd probably use AppleScript. On Linux, xdotool can send keystrokes to arbitrary appliations (see unix.stackexchange.com/questions/87831/…). This is now a separate question that you should open on probably a different SE site. – mankoff Jan 31 at 13:37
  • 3
    Thanks for the pointer. That gives me a very good place to start! Incidentally I found another satisfactory solution, at least for Chrome, which is to append #:~:text=<Searchstring> to your URL and Chrome will open the site and do the search. For example, the following URL will load your profile page and highlight your gold badge https://emacs.stackexchange.com/users/91/mankoff#:~:text=Famous%20Question – Ruy Jan 31 at 15:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.