emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org 7c9a5216bb 1/2: ol-man.el: Enable completion


From: ELPA Syncer
Subject: [elpa] externals/org 7c9a5216bb 1/2: ol-man.el: Enable completion
Date: Thu, 14 Dec 2023 12:58:15 -0500 (EST)

branch: externals/org
commit 7c9a5216bb63f98f7663f8c568a84d77a02ca671
Author: Max Nikulin <manikulin@gmail.com>
Commit: Ihor Radchenko <yantar92@posteo.net>

    ol-man.el: Enable completion
    
    * lisp/ol-man.el (org-man-complete): New function implementing
    completion for man pages using `Man-completion-table'.  Set this
    function as the `:complete' property of "man" links.
    
    Ihor Radchenko. Re: Completion of links to man pages.
    Sat, 09 Dec 2023 11:32:39 +0000.
    <https://list.orgmode.org/877clnsjag.fsf@localhost>
---
 etc/ORG-NEWS   |  6 ++++++
 lisp/ol-man.el | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 9858df0450..6c81221c18 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -729,6 +729,12 @@ respected.
 Images dropped also respect the value of ~org-yank-image-save-method~
 when ~org-yank-dnd-method~ is =attach=.
 
+*** Add completion for links to man pages
+
+Completion is enabled for links to man pages added using ~org-insert-link~:
+=C-c C-l man RET emacscl TAB= to get =emacsclient=.  Of course, the ~ol-man~
+library should be loaded first.
+
 ** New functions and changes in function arguments
 *** ~org-fold-hide-drawer-all~ is now interactive
 
diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index b0701c6896..f5533c5a5c 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -34,6 +34,7 @@
 (require 'ol)
 
 (org-link-set-parameters "man"
+                         :complete #'org-man-complete
                         :follow #'org-man-open
                         :export #'org-man-export
                         :store #'org-man-store-link)
@@ -99,6 +100,17 @@ BACKEND is the current export backend."
      ((eq backend 'md) (format "[%s](%s)" desc path))
      (t path))))
 
+(defun org-man-complete (&optional _arg)
+  "Complete man pages for `org-insert-link'."
+  (require 'man)
+  (concat
+   "man:"
+   (let ((completion-ignore-case t) ; See `man' comments.
+         (Man-completion-cache)) ; See `man' implementation.
+     (completing-read
+      "Manual entry: "
+      'Man-completion-table))))
+
 (provide 'ol-man)
 
 ;;; ol-man.el ends here



reply via email to

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