Skip to content

Commit 6e9ea3a

Browse files
maxnikulinyantar92
authored andcommitted
org.el: Preserve case for link subgroups from `org-file-apps'
* lisp/org.el (org-open-file): Avoid matching of `org-file-apps' records against the link converted to downcase since it caused incorrect substitutions to the command. Consider the following entry (add-to-list 'org-file-apps '("\\.PDF\\(?:\\.[gx]z\\|\\.bz2\\)?::\\(#[^:]*\\)::\\(.+\\)\\'" . "okular --find %2 -- %s%1")) and the link <file:///usr/share/doc/bash/bashref.pdf::#Redirections::before> Without the patch okular --find before -- /usr/share/doc/bash/bashref.pdf\#redirections command is executed and the application can not resolve internal cross-reference anchor. In https://list.orgmode.org/4B51D104.9090502@jboecker.de/T/#u https://list.orgmode.org/k2jfb2eb6811004041733zf176e0aq8367924746db81f5@mail.gmail.com/T/#u the purpose of `dlink' is not clarified, so I assume that the only purpose is to allow matching file suffixes, e.g. ".pdf" vs ".PDF".
1 parent 33686b9 commit 6e9ea3a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lisp/org.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8134,7 +8134,6 @@ If the file does not exist, throw an error."
81348134
(link (cond (line (concat file "::" (number-to-string line)))
81358135
(search (concat file "::" search))
81368136
(t file)))
8137-
(dlink (downcase link))
81388137
(ext
81398138
(and (string-match "\\`.*?\\.\\([a-zA-Z0-9]+\\(\\.gz\\)?\\)\\'" dfile)
81408139
(match-string 1 dfile)))
@@ -8159,8 +8158,9 @@ If the file does not exist, throw an error."
81598158
;; First, try matching against apps-dlink if we
81608159
;; get a match here, store the match data for
81618160
;; later.
8162-
(let ((match (assoc-default dlink apps-dlink
8163-
'string-match)))
8161+
(let* ((case-fold-search t)
8162+
(match (assoc-default link apps-dlink
8163+
'string-match)))
81648164
(if match
81658165
(progn (setq link-match-data (match-data))
81668166
match)
@@ -8191,7 +8191,7 @@ If the file does not exist, throw an error."
81918191
(user-error "No such file: %s" file))
81928192
(cond
81938193
((org-string-nw-p cmd)
8194-
(setq cmd (org--open-file-format-command cmd file dlink link-match-data))
8194+
(setq cmd (org--open-file-format-command cmd file link link-match-data))
81958195

81968196
(save-window-excursion
81978197
(message "Running %s...done" cmd)

0 commit comments

Comments
 (0)