emacs-orgmode
[Top][All Lists]
Advanced

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

[PATCH] org.el: Fix percent substitutions in `org-open-file'


From: Max Nikulin
Subject: [PATCH] org.el: Fix percent substitutions in `org-open-file'
Date: Sun, 28 Aug 2022 00:20:02 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 21/03/2021 19:36, Maxim Nikulin wrote:
On 13/02/2021 11:38, Kyle Meyer wrote:
+(defun org--open-file-format-spec (format specification)
+  (with-temp-buffer
+    (insert format)
+    (goto-char (point-min))
+    (while (search-forward "%" nil t)
+      (cond ((eq (char-after) ?%)
+             (delete-char 1))
+            ((looking-at "[s0-9]")
+             (replace-match
+              (or (cdr (assoc (match-string 0) specification))
+                  (error "Invalid format string"))
+              'fixed-case 'literal)
+             (delete-region (1- (match-beginning 0)) (match-beginning 0)))

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.

Attachment: 0001-org.el-Fix-percent-substitutions-in-org-open-file.patch
Description: Text Data


reply via email to

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