diff --git a/lisp/ol.el b/lisp/ol.el index 0cb1b0a7e..32a80ee56 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -138,6 +138,13 @@ link. Function that inserts a link with completion. The function takes one optional prefix argument. +`:description' + + Function to use for generating link descriptions from links. This + function must take two parameters: the first one is the link, the + second one is the description generated by `org-insert-link'. The + function should return the description to use. + `:display' Value for `invisible' text property on the hidden parts of the @@ -193,16 +200,6 @@ You can interactively set the value of this variable by calling :type 'boolean :safe #'booleanp) -(defcustom org-link-make-description-function nil - "Function to use for generating link descriptions from links. -This function must take two parameters: the first one is the -link, the second one is the description generated by -`org-insert-link'. The function should return the description to -use." - :group 'org-link - :type '(choice (const nil) (function)) - :safe #'null) - (defcustom org-link-file-path-type 'adaptive "How the path name in file links should be stored. Valid values are: @@ -1742,10 +1739,8 @@ If the LINK-LOCATION parameter is non-nil, this value will be used as the link location instead of reading one interactively. If the DESCRIPTION parameter is non-nil, this value will be used as the -default description. Otherwise, if `org-link-make-description-function' -is non-nil, this function will be called with the link target, and the -result will be the default link description. When called non-interactively, -don't allow to edit the default description." +default description. When called non-interactively, don't allow to +edit the default description." (interactive "P") (let* ((wcf (current-window-configuration)) (origbuf (current-buffer)) @@ -1890,17 +1885,27 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (setq desc path))))) (unless auto-desc - (let ((initial-input - (cond - (description) - ((not org-link-make-description-function) desc) - (t (condition-case nil - (funcall org-link-make-description-function link desc) - (error - (message "Can't get link description from %S" - (symbol-name org-link-make-description-function)) - (sit-for 2) - nil)))))) + (let* ((type (and (string-match "\\([^:]+\\):" link) + (match-string-no-properties 1 link))) + (initial-input + (cond + (description) + ((org-link-get-parameter type :description) + (condition-case nil + (funcall (org-link-get-parameter type :description) link desc) + (error + (message "Can't get link description from %S" + (symbol-name (org-link-get-parameter type :description))) + (sit-for 2) + nil))) + ((not org-link-make-description-function) desc) + (t (condition-case nil + (funcall org-link-make-description-function link desc) + (error + (message "Can't get link description from %S" + (symbol-name org-link-make-description-function)) + (sit-for 2) + nil)))))) (setq desc (if (called-interactively-p 'any) (read-string "Description: " initial-input) initial-input)))) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 635a38dcd..c17d888fc 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -376,6 +376,21 @@ See `org-link-parameters' for documentation on the other parameters." (make-obsolete 'org-add-link-type "use `org-link-set-parameters' instead." "Org 9.0") +(defcustom org-link-make-description-function nil + "Function to use for generating link descriptions from links. +This function must take two parameters: the first one is the +link, the second one is the description generated by +`org-insert-link'. The function should return the description to +use." + :group 'org-link + :type '(choice (const nil) (function)) + :safe #'null) + +(make-obsolete-variable + 'org-link-make-description-function + "use `org-link-set-parameters' to set :description link parameter instead." + "Org 9.3.6") + ;;;; Functions unused in Org core. (defun org-table-recognize-table.el () "If there is a table.el table nearby, recognize it and move into it." @@ -516,8 +531,10 @@ use of this function is for the stuck project list." (define-obsolete-variable-alias 'org-email-link-description-format 'org-link-email-description-format "Org 9.3") -(define-obsolete-variable-alias 'org-make-link-description-function - 'org-link-make-description-function "Org 9.3") +(make-obsolete-variable + 'org-make-link-description-function + "use `org-link-set-parameters' to set :description link parameter instead." + "Org 9.3.6") (define-obsolete-variable-alias 'org-from-is-user-regexp 'org-link-from-user-regexp "Org 9.3")