org-insert-link: Do not expand path arg when `org-link-file-path-type' is a function

* lisp/ol.el (org-insert-link): Drop `expand-file-name'.
(org-link-file-path-type): Update docstring.
* etc/ORG-NEWS (When ~org-link-file-path-type~ is a function, its
argument is now a filename as it  in the link; not an absolute
path): Announce the change.

Link: https://orgmode.org/list/871qahl0un.fsf@localhost
This commit is contained in:
Ihor Radchenko 2024-02-17 16:25:19 +01:00
parent c9fc4c03e8
commit 388ba5b5c4
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,12 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.7 (not released yet)
** Important announcements and breaking changes
*** When ~org-link-file-path-type~ is a function, its argument is now a filename as it is read by ~org-insert-link~; not an absolute path
Previously, when ~org-link-file-path-type~ is set to a function, the
function argument was the filename from the link expanded via
~expand-file-name~. Now, a bare filename is passed to the function.
*** Org export backends can now disable citation processors
A new global export option ~:with-cite-processors~, when set to nil,

View File

@ -246,7 +246,7 @@ adaptive Use relative path for files in the current directory and sub-
directories of it. For other files, use an absolute path.
Alternatively, users may supply a custom function that takes the
full filename as an argument and returns the path."
filename in the link as an argument and returns the path."
:group 'org-link
:type '(choice
(const relative)
@ -1979,8 +1979,7 @@ non-interactively, don't allow to edit the default description."
((eq org-link-file-path-type 'relative)
(setq path (file-relative-name path)))
((functionp org-link-file-path-type)
(setq path (funcall org-link-file-path-type
(expand-file-name path))))
(setq path (funcall org-link-file-path-type path)))
(t
(save-match-data
(if (string-match (concat "^" (regexp-quote