emacs-orgmode
[Top][All Lists]
Advanced

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

Completion of links to man pages


From: Max Nikulin
Subject: Completion of links to man pages
Date: Wed, 4 Oct 2023 18:40:49 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

Hi,

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.

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




reply via email to

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