ol.el: Restore complete by description for insert link

* lisp/ol.el (org-insert-link): Allow completion of link target by its
description.  Almost certainly the feature was removed unintentionally.

Link descriptions were added to completion options in
the commit 1e34c5d34 Bastien Guerry,  "org.el: Fontify links to current
buffer when inserting a link", 2012-08-03 14:08:20 +0200
in response to
https://list.orgmode.org/877gw6ocva.fsf@okhotsk19.lowtem.hokudai.ac.jp/T/#u
Yagnesh Raghava Yakkala, "#+LABEL and CUSTOM_ID with reftex",
Mon, 21 May 2012 04:45:29 +0900

List of description was removed from completion options
likely because `ido-completing-read' signals an error in the case of nil
variant (that is not uncommon for links with no description), see the
commit 7f096ad37 Tony Day, "org-insert-link: Use ido when inserting
links", 2012-10-12 14:39:53 +1100 and the discussion of the patch
- https://list.orgmode.org/04D0E787-A8A1-4246-8DD2-D607E38D61BA@gmail.com/T/#u
  tony day.  [PATCH] * org-insert-link: use ido when inserting links.
  Fri, 12 Oct 2012 14:58:29 +1100
- https://list.orgmode.org/5CE03302-7C87-44BE-B4AF-A6A92C96C803@gmail.com/T/#u
  tony day.  [PATCH] org-insert-link: allow ido usage when inserting
  links.  Fri, 14 Sep 2012 19:21:50 +1000
- https://list.orgmode.org/0CADA13B-8A22-4F34-91B1-2232997C1F04@gmail.com/T/#u
  tony day.  [PATCH] org-insert-link: allow ido usage when inserting
  links. Fri, 12 Oct 2012 14:56:10 +1100
- https://list.orgmode.org/97F9790D-3C7F-490B-BE9B-1A652BB9F187@gmail.com/
  tony day.  PATCH: using ido when inserting links.
  Fri, 14 Sep 2012 18:58:43 +1000

Since auto-desc variable added by first commit was not removed
by second one, I assume that disabling the feature was a side effect
rather than the purpose.
This commit is contained in:
Max Nikulin 2022-09-10 17:23:13 +07:00 committed by Ihor Radchenko
parent c9db3c51ab
commit 0432f4fe6b
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 6 additions and 1 deletions

View File

@ -1878,7 +1878,12 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
"Link: "
(append
(mapcar (lambda (x) (concat x ":")) all-prefixes)
(mapcar #'car org-stored-links))
(mapcar #'car org-stored-links)
;; Allow description completion. Avoid "nil" option
;; in the case of `completing-read-default' and
;; an error in `ido-completing-read' when some links
;; have no description.
(delq nil (mapcar 'cadr org-stored-links)))
nil nil nil
'org-link--history
(caar org-stored-links)))