> From: Ihor Radchenko <yanta...@posteo.net> > Cc: maniku...@gmail.com, emacs-orgmode@gnu.org, emacs-de...@gnu.org > Date: Thu, 05 Oct 2023 16:53:57 +0000 > > Eli Zaretskii <e...@gnu.org> writes: > > >> > How is it different from the "M-x man" completion we already have? > >> > >> M-x man will display the man page, while we just need `completing-read' > >> from the same source M-x man or M-x woman use. > > > > Sorry, I don't understand: "M-x man" does provide completion. > > 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. > > And what do you mean by "`completing-read' from the same source M-x > > man or M-x woman use"? > > > > IOW, I think I have no clue of what are you trying to accomplish, > > sorry. > > We aim to create Org links like [[man:ls]]. > To create a link in Org, the interface is C-c C-l (org-insert-link), > which then prompts for link type (man:) and link path (ls). > When querying for the path, we want to have the same completion > COLLECTION as M-x man/woman has. 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? > 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. > What I am asking here is to provide a stable Elisp API for the above use > case. Currently, we have to rely on implementation details. >From where I stand, we have already a stable API tested by years of use. What is maybe missing is some documentation to allow its easier use, that's all.