emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org,  Kyle Meyer <kyle@kyleam.com>
Subject: Re: [PATCH] org.el: Fix percent substitutions in `org-open-file'
Date: Fri, 02 Sep 2022 20:08:17 +0800	[thread overview]
Message-ID: <87tu5qm11q.fsf@localhost> (raw)
In-Reply-To: <dc30fb1c-f947-2797-5cc9-756094cf815c@gmail.com>

Max Nikulin <manikulin@gmail.com> writes:

> It's pity that this issue has not fix yet. I have tried to implement 
> another helper function. It is hardly usable outside of `org-open-file' 
> (perhaps it is still suitable to make mailcap commands), but separate 
> function makes the code testable. I hope, the attached patch fixes the 
> problems with multiple regexp groups and with percent characters in 
> replacement string. Notice that "\%", not "%%" is used to escape percent 
> in mailcap, anyway neither variant was supported before.
> From 2f2850dcdc0cba8cfc6c0e21fc893c4e664d575c Mon Sep 17 00:00:00 2001
> From: Max Nikulin <manikulin@gmail.com>
> Date: Sat, 27 Aug 2022 23:51:24 +0700
> Subject: [PATCH] org.el: Fix percent substitutions in `org-open-file'

Thanks! LGTM, except one comment.

> +(defun org--open-file-format-command
> +    (mailcap-command file link match-data)
> +  "Format MAILCAP-COMMAND to launch viewer for FILE.
> +
> ...
> +For example, to specify particular location withing a PDF file,
> +`org-file-apps' list may have the following entries (order is important):
> +
> +    ;; Page and search string,
> +    ;; e.g. <file:///usr/share/doc/bash/bashref.pdf::34::order of redirections>.
> +    (\"\\\\.pdf::\\\\([0-9]+\\\\)::\\\\(.+\\\\)\\\\\\='\"
> +        . \"okular --page %1 --find %2 %s\")
> +    ;; Internal anchor and search string,
> +    ;; e.g. <file:///usr/share/doc/bash/bashref.pdf::Redirections::allocate a file>.
> +    (\"\\\\.pdf::\\\\(.+\\\\)::\\\\(.+\\\\)\\\\\\='\"
> +        . \"okular --find %2 file://%s\\\\\\\\#%1\")
> +    ;; Page number, e.g. <file:///usr/share/doc/bash/bashref.pdf::34>.
> +    (\"\\\\.pdf::\\\\([0-9]+\\\\)\\\\\\='\" . \"okular --page %1 %s\")
> +    ;; Internal reference, e.g. <file:///usr/share/doc/bash/bashref.pdf::Redirections>.
> +    (\"\\\\.pdf::\\\\(.+\\\\)\\\\\\='\" . \"okular file://%s\\\\\\\\#%1\")
> +    ;; No location within the file, optionally followed by \"::\",
> +    ;; e.g. <file:///usr/share/doc/bash/bashref.pdf>.
> +    (\"\\\\.pdf\\\\(?:::\\\\)?\\\\\\='\" . \"okular %s\")

This is a nice set of examples, but it probably does not belong to this
docstring. I'd rather see this in `org-file-apps' docstring or even in
the manual.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


  reply	other threads:[~2022-09-02 12:08 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
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 [this message]
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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=87tu5qm11q.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    --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 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).