emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: greedy substitution in org-open-file
Date: Fri, 12 Feb 2021 23:46:03 +0700	[thread overview]
Message-ID: <s06bcc$uqt$1@ciao.gmane.io> (raw)
In-Reply-To: <874kih92nb.fsf@kyleam.com>

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	other threads:[~2021-02-12 16:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 16:08 greedy substitution in org-open-file Maxim Nikulin
2021-02-12  7:16 ` Kyle Meyer
2021-02-12 16:46   ` Maxim Nikulin [this message]
2021-02-13  4:38     ` Kyle Meyer
2021-02-15 17:04       ` Maxim Nikulin
2021-03-03 12:47       ` Maxim Nikulin
2021-03-21 12:36       ` Maxim Nikulin
2022-08-27 17:20         ` [PATCH] org.el: Fix percent substitutions in `org-open-file' Max Nikulin
2022-09-02 12:08           ` Ihor Radchenko
2022-09-02 15:41             ` Max Nikulin
2022-09-03  8:26               ` Ihor Radchenko
2022-09-04 12:16                 ` [PATCH v2] " Max Nikulin
2022-09-05  5:46                   ` 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:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='s06bcc$uqt$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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 public inbox


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).