org-link-open-as-file: Do not try dired wildcard expansion when file exists

* lisp/ol.el (org-link-open-as-file): When PATH points to an existing
file and contains wildcard chars, do not try to list all the files in
`dired'.

Reported-by: Edgar Lux <edgarlux@mailfence.com>
Link: https://orgmode.org/list/1294251072.453751.1712943418634@ichabod.co-bxl
This commit is contained in:
Ihor Radchenko 2024-04-13 15:47:18 +03:00
parent 5128460f94
commit 6cb088972f
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 3 additions and 2 deletions

View File

@ -1326,8 +1326,9 @@ This function is meant to be used as a possible tool for
(match-string 1 path)))
(file-name (if (not option) path
(substring path 0 (match-beginning 0)))))
(if (string-match "[*?{]" (file-name-nondirectory file-name))
(dired file-name)
(if (and (string-match "[*?{]" (file-name-nondirectory file-name))
(not (file-exists-p file-name)))
(dired file-name)
(apply #'org-open-file
file-name
arg