From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.orgmode,gmane.emacs.devel Subject: Re: Completion of links to man pages Date: Thu, 05 Oct 2023 20:11:26 +0300 Message-ID: <83mswx2dvl.fsf@gnu.org> References: <87sf6pi9fn.fsf@localhost> <838r8h3w3f.fsf@gnu.org> <87zg0xgimp.fsf@localhost> <83ttr52fmx.fsf@gnu.org> <87sf6pggd6.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19305"; mail-complaints-to="usenet@ciao.gmane.io" Cc: manikulin@gmail.com, emacs-orgmode@gnu.org, emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Thu Oct 05 19:12:20 2023 Return-path: Envelope-to: geo-emacs-orgmode@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qoRtc-0004nF-0W for geo-emacs-orgmode@m.gmane-mx.org; Thu, 05 Oct 2023 19:12:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoRse-0005Ji-LE; Thu, 05 Oct 2023 13:11:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoRsc-0005Iu-Ki; Thu, 05 Oct 2023 13:11:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoRsc-00040o-Bm; Thu, 05 Oct 2023 13:11:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6R8kzEnQTJaichvpN6bHNwBa9VyylZBHSZBkDrsAglc=; b=aHFGXfCzSLd7 lzaqUuqwhwDPtdeGnvlLCDGmdu0BX4jQB9skNc+XIK/Om8uorxnGyYsA0qXUfGavw2/BpUE1n0Fcz hILLeBYy6YjoNGSh13f+jwicuG4RfyJDUr12sPy8muhx3kEchj5/R/00CizA9BfqraXYQJOxmrG/0 1UTZpLW8T90L4UUnmetwccOXVse8b5+D4VMKncem1T29/8Dy53eA4z26HVnauezMaR4mm6r7DAzzd E/9TEws/XhjlGECi7RqmBNbq7CNOf116/o4bsybIIKcyZc28e5f+ydDZ1gsu2g8BtSdnp2aiv2Bdg hpueb9hrJoSd7Vn9zYLeCw==; In-Reply-To: <87sf6pggd6.fsf@localhost> (message from Ihor Radchenko on Thu, 05 Oct 2023 16:53:57 +0000) X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Original-Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.orgmode:157596 gmane.emacs.devel:311309 Archived-At: > From: Ihor Radchenko > Cc: manikulin@gmail.com, emacs-orgmode@gnu.org, emacs-devel@gnu.org > Date: Thu, 05 Oct 2023 16:53:57 +0000 > > Eli Zaretskii 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.