From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.orgmode,gmane.emacs.devel Subject: Re: Completion of links to man pages Date: Thu, 05 Oct 2023 16:53:57 +0000 Message-ID: <87sf6pggd6.fsf@localhost> References: <87sf6pi9fn.fsf@localhost> <838r8h3w3f.fsf@gnu.org> <87zg0xgimp.fsf@localhost> <83ttr52fmx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22526"; mail-complaints-to="usenet@ciao.gmane.io" Cc: manikulin@gmail.com, emacs-orgmode@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Thu Oct 05 18:53:40 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 1qoRbX-0005ar-Mh for geo-emacs-orgmode@m.gmane-mx.org; Thu, 05 Oct 2023 18:53:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoRae-0005r5-Lm; Thu, 05 Oct 2023 12:52:45 -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 1qoRac-0005qh-EU for emacs-orgmode@gnu.org; Thu, 05 Oct 2023 12:52:43 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoRaa-0006i7-6y for emacs-orgmode@gnu.org; Thu, 05 Oct 2023 12:52:42 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id F3F23240029 for ; Thu, 5 Oct 2023 18:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1696524758; bh=xyAoX0XR/c5h3xOPrHt4Q2wIZ5siAKDqgy1d7BLSkPA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=fu0gXXzWt8p7RlpZFhvdkc8P0qb0imiXM4avSdRAq3MunEet4sW6JATah4Oll5zLB tL1/hPqHs8zJ3c3e+nIWOFxWvVUF0+2pyAoGYVcrYIte9Ztu0UFfG0lxk2odlXG3yG As7vZc1lEErUpNgLLyI40JE6GUt1GQ6jEc3AiaxKPGQobqfK5s2RDszDJiXCE0QIfZ twd9LonF1QJnzyI0Cyvderof9yLodnsfdmXN235aQz43ES7hKr7WYNPb8UDBTEOerO fHTtyqjkM9ENz0t0Rs9sA+m87WHomGmacFGj72A824CsRJ8VpVrXkOIfXo6cZJUdxE jMLtAht0Qnklg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S1d051yPkz9rxD; Thu, 5 Oct 2023 18:52:36 +0200 (CEST) In-Reply-To: <83ttr52fmx.fsf@gnu.org> Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:157594 gmane.emacs.devel:311307 Archived-At: 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. > 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. 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))) (defun org-man--init-woman-cache (&optional re-cache) ;; <- implementation detail in woman.el (unless (and (not re-cache) (or (and woman-expanded-directory-path woman-topic-all-completions) (woman-read-directory-cache))) (setq woman-expanded-directory-path (woman-expand-directory-path woman-manpath woman-path)) (setq woman-totic-all-completions (woman-topic-all-completions woman-expand-directory-path)) (woman-write-directory-cache))) (defun org-man--complete-woman (prompt) (require 'woman) (org-man--init-woman-cache) (completing-read prompt woman-topic-all-completions)) However, `Man-completion-table' is not documented (no docstring), `woman-topic-all-completions' is tricky to use - we have to copy-paste cache initialization code and later make sure that we keep things up to date to upstream. 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. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at