Eli Zaretskii <e...@gnu.org> writes: >> Yes, but one cannot replicate the same completion dialogue >> programmatically in future-compatible way. > > What do you mean by that? "M-x man" does this: > > (interactive > (list (let* ((default-entry (Man-default-man-entry)) > ;; ignore case because that's friendly for bizarre > ;; caps things like the X11 function names and because > ;; "man" itself is case-insensitive on the command line > ;; so you're accustomed not to bother about the case > ;; ("man -k" is case-insensitive similarly, so the > ;; table has everything available to complete) > (completion-ignore-case t) > Man-completion-cache ;Don't cache across calls. > (input (completing-read > (format-prompt "Manual entry" > (and (not (equal default-entry "")) > default-entry)) > 'Man-completion-table > nil nil nil 'Man-topic-history default-entry))) > > This uses completing-read, as I think you wanted. > ... > Why cannot you reuse Man-completion-table? > >> For now, as you can see in the quoted code from my initial message, we >> have to partially replicate the code from man.el and woman.el: >> >> (defun org-man--complete-man (prompt) >> (require 'man) >> (let (Man-completion-cache) ;; <- implementation detail in man.el >> (completing-read >> prompt >> 'Man-completion-table))) > > And why is that a problem?
Because we also need to bind (completion-ignore-case t) and (Man-completion-cache nil). Ideally, these details should not be something we need to know. It would be better if man.el provided some kind of API function like `man-completing-read' that takes care about these details, which are apparently necessary to avoid bug#13160 and bug#3717. >> However, `Man-completion-table' is not documented (no docstring), > > If the only thing that's missing is its doc string, that is easy to > add. Docstring would certainly help. Otherwise, we have to guess what that function does. -- Ihor Radchenko // yantar92, 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>