From: "Juan Manuel Macías" <maciaschain@posteo.net>
To: Maxim Nikulin <manikulin@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Org mode links: Open a PDF file at a given page and highlight a given string
Date: Wed, 03 Mar 2021 17:11:09 +0100 [thread overview]
Message-ID: <87sg5cb4ki.fsf@posteo.net> (raw)
In-Reply-To: <s1o7q9$rjc$1@ciao.gmane.io> (Maxim Nikulin's message of "Wed, 3 Mar 2021 21:51:52 +0700")
Hi Maxim
Thanks for your advice, which I appreciate very much.
Maxim Nikulin <manikulin@gmail.com> writes:
> On 03/03/2021 09:31, Juan Manuel Macías wrote:
>> (start-process-shell-command "zathura" nil (concat "zathura "
>> clean-path
>> " -P "
>> pag
>> (when str
>> (format " -f '%s' " str)))))))
>
> Please, do not forget to pass stings coming from user input through
> shell-quote-argument. There is combine-and-quote-strings function but
> its docstring tells that it is not safe enough. Ideally shell should
> be completely avoided in such cases and arguments should be passed as
> a list directly to exec. https://xkcd.com/327/
So, maybe it would look better like this (`start-process' instead of
`start-process-shell-command')?:
#+begin_src emacs-lisp
(org-link-set-parameters
"pdf-pag"
:follow (lambda (path)
(let ((pag (if (string-match "::\\([1-9]+\\):*:*\\(.*\\)" path)
(format "--page=%s" (match-string 1 path))
(error "no pages")))
(clean-path (expand-file-name (replace-regexp-in-string "::.+" "" path)))
(str (when (string-match "::\\([1-9]+\\)::\\(.+\\)" path)
(format "--find=%s" (match-string 2 path)))))
(if str
(start-process "zathura" nil "/usr/bin/zathura"
clean-path
pag
str)
(start-process "zathura" nil "/usr/bin/zathura"
clean-path
pag)))))
#+end_src
Best reagards,
Juan Manuel
next prev parent reply other threads:[~2021-03-03 16:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sg5cb4ki.fsf@posteo.net \
--to=maciaschain@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.