emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: greedy substitution in org-open-file


From: Maxim Nikulin
Subject: Re: greedy substitution in org-open-file
Date: Fri, 12 Feb 2021 23:46:03 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 12/02/2021 14:16, Kyle Meyer wrote:
#+begin_src elisp
    (setq org-file-apps '(("\\.pdf::\\([0-9]+\\)\\'" . "xpdf %s %1")))
#+end_src

Not relevant for the underlying issue, but doesn't xpdf require a colon
before the page number (i.e. ":%1")?

At least for the application in debian & ubuntu xpdf package, page number should be specified without a colon. It is Xt interface to poppler PDF library, recently its maintainer decided to switch to xpopple project as upstream. UI is derived from old version of xpdf. Latest original xpdf version is based on Qt and might have different convention in respect to page numbers.

I believe format-spec requires the placeholder to be A-z:

   (format-spec "xpdf %s" '((?s . "a")))  => "xpdf a"
   (format-spec "xpdf %s %1" '((?s . "a") (?1 . "b")))  ;; Invalid format string

You are right. I missed that format-spec allows to specify field width, so digits could not be used.

What about flipping the processing, handling the %N placeholders first
and then formatting the file name?  Seems to work on my end, though I
haven't tested it thoroughly.

I could anticipate similar problems if named destinations are involved. I have not checked but I expect that internal links might have "%s" in their names at least for some file types. That is why I would strongly prefer substitutions performed in a single pass. I do not like it, but it seems that simplified variant of format-spec is better. It should allows substitutions with digit. I hope, single digit should be enough.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]