[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Org mode links: Open a PDF file at a given page and highlight a give
From: |
Juan Manuel Macías |
Subject: |
Re: Org mode links: Open a PDF file at a given page and highlight a given string |
Date: |
Wed, 03 Mar 2021 03:31:15 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Hi Rodrigo,
Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
> I want to be able to
>
> + create a Org link to specific pages of a PDF. I've managed to
> accomplish this by setting the following value.
> [ ... ]
> + create a Org link to specific pages of a PDF and highlight a given
> string.
A possible alternative, which gives you more control over the link, is
`org-link-set-parameters'. For example:
#+begin_src emacs-lisp
(org-link-set-parameters
"pdf-pag"
:follow (lambda (path)
(let ((pag (if (string-match "::\\([1-9]+\\):*:*\\(.*\\)" path)
(match-string 1 path)
(error "no pages")))
(clean-path (expand-file-name (replace-regexp-in-string
"::.+" "" path)))
(str (when (string-match "::\\([1-9]+\\)::\\(.+\\)" path)
(match-string 2 path))))
(start-process-shell-command "zathura" nil (concat "zathura "
clean-path
" -P "
pag
(when str
(format "
-f '%s' " str)))))))
#+end_src
And then:
#+begin_src org
[[pdf-pag:~/Downloads/grub.pdf::95::do]]
#+end_src
Best regards,
Juan Manuel