emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org mode links: Open a PDF file at a given page and highlight a given string
@ 2021-03-02 20:07 Rodrigo Morales
  2021-03-02 22:36 ` Kyle Meyer
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Rodrigo Morales @ 2021-03-02 20:07 UTC (permalink / raw)
  To: emacs-orgmode


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.

#+begin_src emacs-lisp :results silent
(setq org-file-apps
      '(("\\.pdf::\\([0-9]+\\)\\'" . "zathura -P %1 %s")))
#+end_src

The following links open the PDF at the given page.

[[file:~/Downloads/grub.pdf::10]]

[[file:~/Downloads/grub.pdf::20]]

[[file:~/Downloads/grub.pdf::30]]

+ create a Org link to specific pages of a PDF and highlight a given
  string.

#+begin_src emacs-lisp :results silent
(setq org-file-apps
      '(("\\.pdf::\\([0-9]+\\)::\\([^:]+\\)\\'" . "zathura -P %1 -f %2 %s")))
#+end_src

The following link must open the PDF at a given page and highlight the
given string. However, I'm getting the following error (see the
=#+begin_example= block below.)

[[file:~/Downloads/grub.pdf::95::do]]

#+begin_example
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  replace-match(nil t t "zathura -P 95 -f %2 /home/username/Downloads/grub....")
  org-open-file("~/Downloads/grub.pdf" nil nil "95::do")
  apply(org-open-file "~/Downloads/grub.pdf" nil (nil "95::do"))
  org-link-open((link (:type "file" :path "~/Downloads/grub.pdf" :format bracket :raw-link "file:~/Downloads/grub.pdf::95::do" :application nil :search-option "95::do" :begin 821 :end 858 :contents-begin nil :contents-end nil :post-blank 0 :parent (paragraph (:begin 821 :end 860 :contents-begin 821 :contents-end 859 :post-blank 1 :post-affiliated 821 :parent nil)))) nil)
  org-open-at-point(nil)
  funcall-interactively(org-open-at-point nil)
  call-interactively(org-open-at-point nil nil)
  command-execute(org-open-at-point)
#+end_example

Note that the following accomplishes what I'm looking for

#+begin_src bash
zathura -P 95 -f do ~/Downloads/grub.pdf
#+end_src

My question is: How can I get rid of that error so that the PDF is
opened at a given page and the string is highlighted?

PS: If you want a PDF to test the link presented in this message, you
can download the following PDF (564K). It was the smallest PDF in
gnu.org I was able to find.

#+begin_src bash :dir ~/Downloads :results silent
wget 'https://www.gnu.org/software/grub/manual/grub/grub.pdf'
#+end_src

-- 
Greetings,
Rodrigo Morales.

IRC: rdrg109 (freenode)


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-01-25 14:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 20:07 Org mode links: Open a PDF file at a given page and highlight a given string Rodrigo Morales
2021-03-02 22:36 ` Kyle Meyer
2021-03-03 12:37   ` Maxim Nikulin
2021-09-27 16:39   ` Max Nikulin
2021-03-03  2:31 ` Juan Manuel Macías
2021-03-03 14:51   ` Maxim Nikulin
2021-03-03 16:11     ` Juan Manuel Macías
2021-03-05 13:02       ` Maxim Nikulin
2022-09-03 13:00 ` Max Nikulin
2022-09-20 11:54   ` Ihor Radchenko
2022-09-20 17:03     ` Max Nikulin
2022-09-21  8:17       ` Ihor Radchenko
2022-09-21  8:18       ` Ihor Radchenko
2023-01-25 11:46         ` AW
2023-01-25 11:55           ` Ihor Radchenko
2023-01-25 12:35           ` Max Nikulin
2023-01-25 14:33           ` Jean Louis
2022-10-04  6:45 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).