1

I read pdfs with pdf-tools, but I think what I'm asking may apply to more than pdf-tools alone.

In any case, as an example, some research paper pdfs have references with clickable links - say a link to the journal as in: http://journal-name.com/article-id. When the link is clicked, the browser opens up and redirects to the URL specified in the link.

So far so good. What I would like to know though, is if would be possible to have links redirect somewhere else. Instead of going to the journal website, I would like to know whether clicks could redirect to https://my-website.tw/http://journal-name.com/article-id instead (perhaps only when the link matches a regexp).

How would something in these lines be implemented?

I don't even know what function to change, because calling C-h k on a mouse press seems to show me a function that is completely irrelevant to following links.

3

I'll answer your actual problem of modifying the action for following links with pdf-tools.

The customizable option pdf-links-browse-uri-function holds a function that receives a string with the uri as an argument and should take the appropriate action, e.g., open the link in a browser.

You can define your own function and register it there with M-x customize-option.


The formulation of the title of your question "How can I change what happens when I click on a link?" is very general. It is even still quite involved if you narrow it down to pdf-tools.

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.