emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ol.el: Recommend `browse-url' to `:follow' links
@ 2023-02-09 15:46 Max Nikulin
  2023-02-10 11:13 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Max Nikulin @ 2023-02-09 15:46 UTC (permalink / raw)
  To: emacs-orgmode

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

I think, it might be helpful to mention the `browse-url' package in the 
docs for the :follow property of `org-link-parameters'. Writing code to 
launch an external application may be tricky, so it is better to 
delegate the task to existing utilities.

[-- Attachment #2: 0001-ol.el-Recommend-browse-url-to-follow-links.patch --]
[-- Type: text/x-patch, Size: 1465 bytes --]

From 9d6b216d4bd654f976cd889dec2f805f05f76428 Mon Sep 17 00:00:00 2001
From: Max Nikulin <manikulin@gmail.com>
Date: Thu, 9 Feb 2023 22:31:51 +0700
Subject: [PATCH] ol.el: Recommend `browse-url' to `:follow' links

* lisp/ol.el (org-link-parameters): Recommend the `browse-url' function
for calling external protocol handlers in the docstring.

This is indirect follow-up of the
https://list.orgmode.org/3218434.44csPzL39Z@linux.fritz.box/ thread.
---
 lisp/ol.el | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lisp/ol.el b/lisp/ol.el
index 9e4781f6e..dd883ab29 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -109,6 +109,20 @@ (defcustom org-link-parameters nil
   Here, you may use `org-link-open-as-file' helper function for
   types similar to \"file\".
 
+  To invoke an external handler of specific URI scheme such as \"irc:\",
+  consider delegating the task to `browse-url', for details
+  see Info node `(emacs) Browse-URL'.
+
+    (lambda (path &optional arg)
+      (browse-url (concat type \":\" path) arg))
+
+  Either ensure that a system-wide protocol handler is configured or
+  add an entry to `browse-url-handlers' for Emacs-28 and newer
+  or define `browse-url-browser-function' as alist for older versions.
+  The advantage of this approach is that the same handler
+  will be available for `goto-address-mode'
+  (see Info node `(emacs) Goto Address mode').
+
 `:export'
 
   Function that accepts four arguments:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ol.el: Recommend `browse-url' to `:follow' links
  2023-02-09 15:46 [PATCH] ol.el: Recommend `browse-url' to `:follow' links Max Nikulin
@ 2023-02-10 11:13 ` Ihor Radchenko
  2023-02-10 12:23   ` Max Nikulin
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-02-10 11:13 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> I think, it might be helpful to mention the `browse-url' package in the 
> docs for the :follow property of `org-link-parameters'. Writing code to 
> launch an external application may be tricky, so it is better to 
> delegate the task to existing utilities.

Maybe better add this to "A.3 Adding Hyperlink Types" section of the manual?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ol.el: Recommend `browse-url' to `:follow' links
  2023-02-10 11:13 ` Ihor Radchenko
@ 2023-02-10 12:23   ` Max Nikulin
  2023-02-11 12:01     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Max Nikulin @ 2023-02-10 12:23 UTC (permalink / raw)
  To: emacs-orgmode

On 10/02/2023 18:13, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>> I think, it might be helpful to mention the `browse-url' package in the
>> docs for the :follow property of `org-link-parameters'. Writing code to
>> launch an external application may be tricky, so it is better to
>> delegate the task to existing utilities.
> 
> Maybe better add this to "A.3 Adding Hyperlink Types" section of the manual?

If you you believe that the (info "(org) Adding Hyperlink Types") 
section should be expanded then a complete example is necessary, some 
ideas may be picked from

https://orgmode.org/worg/org-faq.html#mailto-links
https://orgmode.org/worg/org-faq.html#mid-url-handler

While the manual section and the `org-link-parameters' docstring as the 
reference may be cross-linked, some note on `browse-url' still may be 
helpful in the latter.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ol.el: Recommend `browse-url' to `:follow' links
  2023-02-10 12:23   ` Max Nikulin
@ 2023-02-11 12:01     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-02-11 12:01 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>> Maybe better add this to "A.3 Adding Hyperlink Types" section of the manual?
>
> If you you believe that the (info "(org) Adding Hyperlink Types") 
> section should be expanded then a complete example is necessary, some 
> ideas may be picked from
>
> https://orgmode.org/worg/org-faq.html#mailto-links
> https://orgmode.org/worg/org-faq.html#mid-url-handler
>
> While the manual section and the `org-link-parameters' docstring as the 
> reference may be cross-linked, some note on `browse-url' still may be 
> helpful in the latter.

I believe that examples like yours really belong to the manual, not to
the docstring. Your example is the shortest possible way to define a new
link type as opposed to writing a whole new library - something rather
hard to achieve for less experienced users.

So, I suggest to
1. Put your example to the beginning of "Adding Hyperlink Types" section
   of the manual as the simplest way to define a new link type and
   use ol-man as a more complex example if more features are needed.

2. Refer to (info "(org) Adding Hyperlink Types") from the docstring of
   `org-link-parameters'.

WDYT?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-11 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 15:46 [PATCH] ol.el: Recommend `browse-url' to `:follow' links Max Nikulin
2023-02-10 11:13 ` Ihor Radchenko
2023-02-10 12:23   ` Max Nikulin
2023-02-11 12:01     ` Ihor Radchenko

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