Max Nikulin <maniku...@gmail.com> writes: > I believe that descriptions as completion options were removed because > ido signals an error when nil is passed inside completion list. I > consider it as a bug in ido (at least in Emacs-27), but even when > `completing-read-default' is used, it causes appearance of undesired > "nil" option. No description is a frequent case for links.
This sounds reasonable. In general, there should be no need to care which completion backend is used by Emacs - they should all plug into `completing-read' without anything special to be done on Org side. The only exception is possible not-yet-fixed bugs in earlier Emacs versions. However, workaround for such issues should be clearly marked by a comment in the code and removed once the problematic Emacs version support is dropped. > So I am attaching a patch to restore completion of link targets by their > description, nil descriptions are filtered out. Thanks! Applied onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=0432f4fe6ba9b07c17ac555beab1527d8f844234 > The change is caused by the auto-desc local variable in > `org-insert-link', its usage is rather strange and confusing currently. > Despite with this patch descriptions are restored, I believe that > logic related to auto-desc should be removed, anyway it was broken for > 10 years. I am unsure in which thread the next change should be discussed. To be frank, org-insert-link should be eventually refactored or at least better commented. This is one of the "old" functions in Org mode and its code style is not ideal. I think that the best approach to fix this and similar functions will be discussing/documenting the overall design of the Org link storage/completion. We can then work towards removing inconsistencies and subtle bugs in the code. Now, even not all the functionality of org-insert-link is described in its docstring (like re-using selected region). -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92