emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Completion of links to man pages


From: Ihor Radchenko
Subject: Re: Completion of links to man pages
Date: Thu, 05 Oct 2023 11:40:44 +0000

[ CCing emacs-devel ]

Max Nikulin <manikulin@gmail.com> writes:

> I am unsure if the code below is appropriate for :complete property of 
> "man" link. It does not rely on any double-dash functions or variables, 
> but it still uses some implementation details since there is no suitable 
> high level functions in man.el and woman.el from Emacs.

Without docstrings, we cannot rely even on single-dash functions.

To emacs-devel: Would it be of interest to expose man/woman completion
API?

> (defun org-man-complete (&optional _arg)
>    "Helper for completion of links to man pages."
>    (concat
>     "man:"
>     (let ((completion-ignore-case t)) ; See `man' comments.

`completion-ignore-case' is not set in woman.

>       (funcall
>        (if (eq org-man-command 'woman)
>            #'org-man--complete-woman
>          #'org-man--complete-man)
>        "Manual entry: "))))
>
> (defun org-man--complete-man (prompt)
>    (require 'man)
>    (let (Man-completion-cache)
>      (completing-read
>       prompt
>       'Man-completion-table)))

> (defun org-man--init-woman-cache (&optional re-cache)
>    (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))

-- 
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>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]