emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: manikulin@gmail.com, emacs-orgmode@gnu.org, emacs-devel@gnu.org
Subject: Re: Completion of links to man pages
Date: Thu, 05 Oct 2023 20:11:26 +0300	[thread overview]
Message-ID: <83mswx2dvl.fsf@gnu.org> (raw)
In-Reply-To: <87sf6pggd6.fsf@localhost> (message from Ihor Radchenko on Thu, 05 Oct 2023 16:53:57 +0000)

> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: manikulin@gmail.com, emacs-orgmode@gnu.org, emacs-devel@gnu.org
> Date: Thu, 05 Oct 2023 16:53:57 +0000
> 
> Eli Zaretskii <eliz@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.


  reply	other threads:[~2023-10-05 17:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 11:40 Completion of links to man pages Max Nikulin
2023-10-05 11:40 ` Ihor Radchenko
2023-10-05 12:20   ` Max Nikulin
2023-10-05 12:48     ` Ihor Radchenko
2023-10-05 15:59       ` Max Nikulin
2023-10-05 16:15         ` Ihor Radchenko
2023-10-05 16:37           ` Eli Zaretskii
2023-10-05 16:55             ` Ihor Radchenko
2023-10-05 17:13               ` Eli Zaretskii
2023-10-05 17:30                 ` Ihor Radchenko
     [not found]                 ` <ufnvit$12ho$1@ciao.gmane.io>
2023-10-06 21:37                   ` Richard Stallman
2023-10-07 11:14                 ` Michael Albinus
2023-10-06  3:58           ` Max Nikulin
2023-10-05 15:52   ` Eli Zaretskii
2023-10-05 16:05     ` Ihor Radchenko
2023-10-05 16:33       ` Eli Zaretskii
2023-10-05 16:53         ` Ihor Radchenko
2023-10-05 17:11           ` Eli Zaretskii [this message]
2023-10-05 17:36             ` Ihor Radchenko
2023-10-06  3:16             ` Max Nikulin
2023-12-09 11:32 ` Ihor Radchenko
2023-12-13 15:20   ` [PATCH] ol-man.el: Enable completion Max Nikulin
2023-12-14 15:09     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83mswx2dvl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).