Skip to content

Commit

Permalink
org.el: Pass link match data to `org-file-apps' functions
Browse files Browse the repository at this point in the history
* lisp/org.el (org--file-apps-entry-dlink-p): Fix it to pass match data
to handler functions from `org-open-file' alist when pattern field of
`org-file-apps' contains regexp subgroups.

Update `org--file-apps-entry-dlink-p' to use current convention for action
field of `org-file-apps' structure.  Currently it may be a function while
earlier s-expression was allowed.  Obsolete test wrongly separated actions
able to handle regexp subgroups matched in the link.  An example when
match data were not passed to the handler function:

    (add-to-list
     'org-file-apps
     '("\\.pdf\\(?:\\.gz\\|\\.bz2\\|\\.xz\\)?\\(?:::.*\\)?\\'"
        . my-open-pdf-locator))

Notice that lambda functions passed `consp' test, so namely
`defun' is required to reproduce the issue.

This change was missed in the commit:

     c8a3ab1 2016-02-03 18:30:17 +0100
     Nicolas Goaziou: `org-file-apps' accept functions instead of sexp

For discussion of the issue with evaluation of arbitrary expression see
https://list.orgmode.org/CALn3zoh+ACSU09eRurfwKjmCnw7i-_0KX7tA2jWqtu=vvQepLQ@mail.gmail.com/T/#u
Michael Brand. org-player and switch to lexical binding in org.el.
Sun, 17 Jan 2016 19:58:38 +0100
  • Loading branch information
maxnikulin authored and yantar92 committed Sep 9, 2022
1 parent eb5ef0a commit 33686b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -8002,7 +8002,7 @@ a parameter."
(> (regexp-opt-depth selector) 0)
(or (and (stringp action)
(string-match "%[0-9]" action))
(consp action))))
(functionp action))))
(_ nil)))

(defun org--file-apps-regexp-alist (list &optional add-auto-mode)
Expand Down

0 comments on commit 33686b9

Please sign in to comment.