[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] org.el: Fix percent substitutions in `org-open-file'
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] org.el: Fix percent substitutions in `org-open-file' |
Date: |
Fri, 02 Sep 2022 20:08:17 +0800 |
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
- Re: [PATCH] org.el: Fix percent substitutions in `org-open-file',
Ihor Radchenko <=