emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ol-man.el: Enable completion
Date: Wed, 13 Dec 2023 22:20:44 +0700	[thread overview]
Message-ID: <ulci4e$du7$1@ciao.gmane.io> (raw)
In-Reply-To: <877clnsjag.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 451 bytes --]

On 09/12/2023 18:32, Ihor Radchenko wrote:
> Considering that the discussion on emacs-devel concluded that woman is
> obsolete, that no interest has been shown in introducing a stable
> completion API, and that the "man" part of the above code is reasonably
> simple, I think that the above two functions would be an OK addition to
> ol-man (with woman part of `org-man-complete' removed).
> 
> Max, may you convert this into a patch?

See attachments

[-- Attachment #2: 0001-ol-man.el-Enable-completion.patch --]
[-- Type: text/x-patch, Size: 2111 bytes --]

From d52265f6242b21561d5f96ae94afb1da37af1ce3 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Mon, 9 Oct 2023 18:47:04 +0700
Subject: [PATCH 1/2] 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 9858df045..6c81221c1 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 b0701c689..f5533c5a5 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -34,6 +34,7 @@ (org-assert-version)
 (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 @@ (defun org-man-export (link description 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
-- 
2.39.2


[-- Attachment #3: 0002-ol-man.el-Mark-WoMan-link-handler-as-obsolete.patch --]
[-- Type: text/x-patch, Size: 1055 bytes --]

From d7ea42febd19825622c9779e197c37c4d9fd0435 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Wed, 13 Dec 2023 22:03:36 +0700
Subject: [PATCH 2/2] ol-man.el: Mark WoMan link handler as obsolete

lisp/ol-man.el (org-man-command): Add label suggesting against
the WoMan package as a viewer for man pages.  It has enough bugs.

Eli Zaretskii to emacs-orgmode. Re: Completion of links to man pages.
Thu, 05 Oct 2023 19:33:26 +0300.
<https://list.orgmode.org/orgmode/83sf6p2fgu.fsf@gnu.org>
---
 lisp/ol-man.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ol-man.el b/lisp/ol-man.el
index f5533c5a5..633280942 100644
--- a/lisp/ol-man.el
+++ b/lisp/ol-man.el
@@ -42,7 +42,7 @@ (org-link-set-parameters "man"
 (defcustom org-man-command 'man
   "The Emacs command to be used to display a man page."
   :group 'org-link
-  :type '(choice (const man) (const woman)))
+  :type '(choice (const man) (const :tag "WoMan (obsolete)" woman)))
 
 (defun org-man-open (path _)
   "Visit the manpage on PATH.
-- 
2.39.2


  reply	other threads:[~2023-12-13 15:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 11:40 Completion of links to man pages Max Nikulin
2023-10-05 11:40 ` Ihor Radchenko
2023-10-05 12:20   ` Max Nikulin
2023-10-05 12:48     ` Ihor Radchenko
2023-10-05 15:59       ` Max Nikulin
2023-10-05 16:15         ` Ihor Radchenko
2023-10-05 16:37           ` Eli Zaretskii
2023-10-05 16:55             ` Ihor Radchenko
2023-10-05 17:13               ` Eli Zaretskii
2023-10-05 17:30                 ` Ihor Radchenko
     [not found]                 ` <ufnvit$12ho$1@ciao.gmane.io>
2023-10-06 21:37                   ` Richard Stallman
2023-10-07 11:14                 ` Michael Albinus
2023-10-06  3:58           ` Max Nikulin
2023-10-05 15:52   ` Eli Zaretskii
2023-10-05 16:05     ` Ihor Radchenko
2023-10-05 16:33       ` Eli Zaretskii
2023-10-05 16:53         ` Ihor Radchenko
2023-10-05 17:11           ` Eli Zaretskii
2023-10-05 17:36             ` Ihor Radchenko
2023-10-06  3:16             ` Max Nikulin
2023-12-09 11:32 ` Ihor Radchenko
2023-12-13 15:20   ` Max Nikulin [this message]
2023-12-14 15:09     ` [PATCH] ol-man.el: Enable completion Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ulci4e$du7$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).