Re: [PATCH] Fix FAQ entry about mailto links.

2022-03-12 Thread Max Nikulin
Sorry for the noise. Another attempt to remove the record from 
https://updates.orgmode.org


Canceled.

Another variant based on 
https://list.orgmode.org/9437ade2-af18-f97e-8790-a2df27c90...@gmail.com 
has been committed.


On 07/01/2022 01:34, Robert Goldman wrote:


The old entry referred to the variable =org-link-mailto-program= which
was removed from org-mode almost eight years ago!  See org-mode commit
b9f2e17f07faf01109fc6f7f1eb5a34e0f97eafb
---
  org-faq.org | 18 +++---
  1 file changed, 15 insertions(+), 3 deletions(-)





Re: [PATCH] Fix FAQ entry about mailto links.

2022-02-10 Thread Robert Goldman

On 7 Feb 2022, at 10:59, Max Nikulin wrote:


Robert,

Thank you for pointing out that `org-link-mailto-program' should not 
be recommended in FAQ any more.


I prepared an alternative patch that recommends to customize Emacs 
variables at first. I hope, an example is safer now, however I can not 
test it on MacOS. Could you, please, review the patch, since I may 
miss something important from your point of view?


On 07/01/2022 18:03, Max Nikulin wrote:

On 07/01/2022 01:34, Robert Goldman wrote:


+You can also change the function used to a different one.  For
+example, the following function (on MacOS) opens =mailto:= links in
+the =MailMate= program:


I am unsure if MailMate is acceptable since it is a proprietary 
application. Org is a part of *GNU* Emacs, so it may be better to 
mention some free mail user agent.



+#+begin_src elisp
+("mailto" :follow

     ^
It seems, `org-link-set-parameters' is missed.


I am sorry, I missed that you suggested to customize the 
`org-link-parameters' variable, so function call is not necessary 
here.


There are a couple of minor issues in the patch you sent (including a 
couple of grammatical errors), so attached is a revision.


I'm afraid there are now multiple patch files.

Please note that I have requested clarification at several places in the 
comment block.


Best,
R


From b8158af7a839a751e6976cd95d18a5d5f199024a Mon Sep 17 00:00:00 2001
From: "Robert P. Goldman" 
Date: Thu, 6 Jan 2022 12:27:59 -0600
Subject: [PATCH 1/4] Fix FAQ entry about mailto links.

The old entry referred to the variable =org-link-mailto-program= which
was removed from org-mode almost eight years ago!  See org-mode commit
b9f2e17f07faf01109fc6f7f1eb5a34e0f97eafb
---
 org-faq.org | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/org-faq.org b/org-faq.org
index 4b34560c..cac8063e 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -1927,13 +1927,13 @@ For example:
 #+index: Link!Mailto
 
 You can customize the function org-mode uses to open mailto links by
-setting the variable =org-link-mailto-program=:
+changing the entry for =mailto:= links in =org-link-parameters=:
 
-=M-x customize-variable org-link-mailto-program=
+=M-x customize-variable org-link-parameters=
 
 The default function called is =browse-url=, which opens a mail
 composition buffer within Emacs. The type of buffer opened by
-browse-url depends on the setting of the variable =mail-user-agent=.
+=browse-url= depends on the setting of the variable =mail-user-agent=.
 Thus, if you want to ensure that mailto links use Gnus to open a
 message buffer, you could add the following to your =.emacs=:
 
@@ -1941,6 +1941,18 @@ message buffer, you could add the following to your 
=.emacs=:
 (setq mail-user-agent 'gnus-user-agent)
 #+end_src
 
+You can also change the function used to a different one.  For
+example, the following function (on MacOS) opens =mailto:= links in
+the =MailMate= program:
+
+#+begin_src elisp
+("mailto" :follow
+  (lambda
+(path)
+(shell-command
+ (format "open -a MailMate 'mailto:%s'" path
+#+end_src
+
 ** Can I use CamelCase links?
:PROPERTIES:
:CUSTOM_ID: CamelCase-links
-- 
2.31.1

From e7f0f2c51950b3c0f181191c5210ea26cafc03f4 Mon Sep 17 00:00:00 2001
From: "Robert P. Goldman" 
Date: Thu, 10 Feb 2022 11:20:36 -0600
Subject: [PATCH 2/4] Revert "Fix FAQ entry about mailto links."

This reverts commit b8158af7a839a751e6976cd95d18a5d5f199024a.
---
 org-faq.org | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/org-faq.org b/org-faq.org
index cac8063e..4b34560c 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -1927,13 +1927,13 @@ For example:
 #+index: Link!Mailto
 
 You can customize the function org-mode uses to open mailto links by
-changing the entry for =mailto:= links in =org-link-parameters=:
+setting the variable =org-link-mailto-program=:
 
-=M-x customize-variable org-link-parameters=
+=M-x customize-variable org-link-mailto-program=
 
 The default function called is =browse-url=, which opens a mail
 composition buffer within Emacs. The type of buffer opened by
-=browse-url= depends on the setting of the variable =mail-user-agent=.
+browse-url depends on the setting of the variable =mail-user-agent=.
 Thus, if you want to ensure that mailto links use Gnus to open a
 message buffer, you could add the following to your =.emacs=:
 
@@ -1941,18 +1941,6 @@ message buffer, you could add the following to your 
=.emacs=:
 (setq mail-user-agent 'gnus-user-agent)
 #+end_src
 
-You can also change the function used to a different one.  For
-example, the following function (on MacOS) opens =mailto:= links in
-the =MailMate= program:
-
-#+begin_src elisp
-("mailto" :follow
-  (lambda
-(path)
-(shell-command
- (format "open -a MailMate 'mailto:%s'" path
-#+end_src
-
 ** Can I use CamelCase links?
:PROPERTIES:
:CUSTOM_ID: CamelCase-links
-- 
2.31.1

From 

Re: [PATCH] Fix FAQ entry about mailto links.

2022-02-07 Thread Max Nikulin

Robert,

Thank you for pointing out that `org-link-mailto-program' should not be 
recommended in FAQ any more.


I prepared an alternative patch that recommends to customize Emacs 
variables at first. I hope, an example is safer now, however I can not 
test it on MacOS. Could you, please, review the patch, since I may miss 
something important from your point of view?


On 07/01/2022 18:03, Max Nikulin wrote:

On 07/01/2022 01:34, Robert Goldman wrote:


+You can also change the function used to a different one.  For
+example, the following function (on MacOS) opens =mailto:= links in
+the =MailMate= program:


I am unsure if MailMate is acceptable since it is a proprietary 
application. Org is a part of *GNU* Emacs, so it may be better to 
mention some free mail user agent.



+#+begin_src elisp
+("mailto" :follow

     ^
It seems, `org-link-set-parameters' is missed.


I am sorry, I missed that you suggested to customize the 
`org-link-parameters' variable, so function call is not necessary here.From 2ace0101654f61361b6f37bf3273f8520f2c Mon Sep 17 00:00:00 2001
From: Max Nikulin 
Date: Mon, 7 Feb 2022 23:40:37 +0700
Subject: [PATCH] FAQ: Update suggestion for mailto: link handlers

org-faq.org (mailto-links): Mention `org-link-mailto-program' as removed
variable, recommend customization of `browse-url-mailto-function' or
`org-link-parameters' instead.

Robert Goldman  in
https://list.orgmode.org/fead92a6-87de-4cff-8459-e3d012dd3...@sift.net
proposed a patch removing mention of `org-link-mailto-program' variable
that is not used in the code for some time.  The patch has an example of
usage `org-link-parameters' to assign custom external handler for
mailto: links.

This change recommends to configure Emacs facilities used by Org as
well.  It has a safer example for `org-link-parameters' customization.
---
 org-faq.org | 87 ++---
 1 file changed, 76 insertions(+), 11 deletions(-)

diff --git a/org-faq.org b/org-faq.org
index 4b34560c..b6bde3ca 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -1926,21 +1926,86 @@ For example:
 
 #+index: Link!Mailto
 
-You can customize the function org-mode uses to open mailto links by
-setting the variable =org-link-mailto-program=:
+Org calls ~browse-url~ function for =mailto:= links, so it should obey
+your Emacs configuration.  If something goes wrong then
+[[info:emacs#Browse-URL][info "(emacs) Browse-URL"]] may be a good starting point.
+
+By default mail is composed in an Emacs buffer.  If you prefer some
+external application instead than set ~browse-url-mailto-function~ to
+nil, e.g. using
+[[elisp:(customize-variable 'browse-url-mailto-function)][=M-x customize-variable RET browse-url-mailto-function RET=]]
+and =mailto:= links will be opened accordingly to
+~browse-url~browser-function~ value.
+
+If you intention is to compose messages in Emacs then consult
+[[info:emacs#Mail Methods][info "(emacs) Mail Methods"]].  Check that ~browse-url-mailto-function~
+has its default value ~browse-url-mail~.  Emacs has several mail
+packages, so next step may be
+[[elisp:(customize-variable 'mail-user-agent)][=M-x customize-variable RET mail-user-agent RET=]] to set the variable
+to e.g. =gnus-user-agent=.
+
+If you prefer an external application other than configured in desktop
+environment then you should write a custom URL handler function.  Be
+careful, try to avoid shell (e.g. ~shell-command~ function) since it
+is easy to mess up with escaping of the URL argument and thus to allow
+execution of arbitrary code.  Some parts of links may be treated as
+shell specials.  Choosing of a proper function to invoke external
+application is a non-trivial task even for seasoned Emacs developers.
+Consult source code of ~browse-url-xdg-open~,
+~browse-url-default-macosx-browser~, or
+~browse-url-default-windows-browser~ for GNU/Linux,
+Mac\nbsp{}OS\nbsp{}X, or MS\nbsp{}Windows platforms accordingly.
 
-=M-x customize-variable org-link-mailto-program=
-
-The default function called is =browse-url=, which opens a mail
-composition buffer within Emacs. The type of buffer opened by
-browse-url depends on the setting of the variable =mail-user-agent=.
-Thus, if you want to ensure that mailto links use Gnus to open a
-message buffer, you could add the following to your =.emacs=:
+#+begin_comment
+Recurring source of pain is interaction of Emacs function with
+=xdg-open=, =kde-open5=, =gio open= utilities on Linux.  While
+~call-process~ with 0 as ~DESTINATION~ argument for
+~browse-url-generic~ was settled in 2004, ~browse-url-xdg-open~ was
+evolving to similar code in 2011.  Notice that application has no
+chance to notify Emacs about failure.
+
+Example of confusion that fortunately was not resulted in changing of
+code: [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=9779#29]] There was
+a lengthy thread "& and M-& to run programs asynchronously" in 2009
+with strange conclusion that it is a bug in Gnome utility:

Re: [PATCH] Fix FAQ entry about mailto links.

2022-01-07 Thread Max Nikulin

On 07/01/2022 01:34, Robert Goldman wrote:


The old entry referred to the variable =org-link-mailto-program= which
was removed from org-mode almost eight years ago!  See org-mode commit
b9f2e17f07faf01109fc6f7f1eb5a34e0f97eafb


Unfortunately FAQ has a lot of obsolete recipes. Generally it is great 
when answers are updated with contemporary info. I have a couple of 
questions concerning your patch though.



diff --git a/org-faq.org b/org-faq.org

  The default function called is =browse-url=, which opens a mail
  composition buffer within Emacs. The type of buffer opened by
-browse-url depends on the setting of the variable =mail-user-agent=.
+=browse-url= depends on the setting of the variable =mail-user-agent=.


[[info:emacs#Browse-URL][info "(emacs) Browse-URL"]] link to the Emacs 
manual might be used. I am unsure however if it is really necessary.



+You can also change the function used to a different one.  For
+example, the following function (on MacOS) opens =mailto:= links in
+the =MailMate= program:
+
+#+begin_src elisp
+("mailto" :follow

^
It seems, `org-link-set-parameters' is missed. I am not an experienced 
emacs user, so my question may be naive. There is 
`browse-url-mailto-function' since Emacs-24.1 that should be called by 
`browse-url'. Is there a reason to avoid its customization instead?



+  (lambda
+    (path)
+    (shell-command
+ (format "open -a MailMate 'mailto:%s'" path
+#+end_src


Shell commands require a lot of care otherwise they become an open door 
to security vulnerabilities. I am a linux user and I have tried a dialog 
application instead of real mailer for a test:


 >8 
#+begin_src elisp :results silent
(org-link-set-parameters
  "mailto" :follow
(lambda
  (path)
  (shell-command
	   (format "zenity --info --no-markup --title 'org mailto: test' --text 
'mailto:%s'" path

#+end_src

[[mailto:Hacker '`mktemp mailto-vulnerability.XX`' ]]
 8< -

Following the link (C-c C-o) caused creation of a file in the current 
directory.


Arguments to shell should be at least passed through 
`shell-quote-argument'. A better way is to use more verbose function 
that accepts arguments as a list and directly executes the binary 
without interpreting anything by shell.


Another problem that the command above blocked emacs session. I do not 
know a reliable way to launch a detached process from emacs. When 
someone adds a code that should perform such task, it usually suffers 
from a decade-old bug 
https://lists.gnu.org/archive/html/emacs-devel/2009-07/msg00279.html 
Current code in `mailcup-view-mime' and in `org-open-file' suffers from 
at least three other problems: I do not know anything about first one 
besides that it is somehow related to compatibility, another one assumed 
to be rather rare, third one is that the process have to be killed on 
exiting from emacs.


So, I hope, `make-process' is better than `shell-command', but a 
specific application might make emacs CPU hungry.


A recipe having security issues, in my opinion, is worse than no example 
at all.





[PATCH] Fix FAQ entry about mailto links.

2022-01-06 Thread Robert Goldman



The old entry referred to the variable =org-link-mailto-program= which
was removed from org-mode almost eight years ago!  See org-mode commit
b9f2e17f07faf01109fc6f7f1eb5a34e0f97eafb
---
 org-faq.org | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/org-faq.org b/org-faq.org
index 4b34560c..cac8063e 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -1927,13 +1927,13 @@ For example:
 #+index: Link!Mailto

 You can customize the function org-mode uses to open mailto links by
-setting the variable =org-link-mailto-program=:
+changing the entry for =mailto:= links in =org-link-parameters=:

-=M-x customize-variable org-link-mailto-program=
+=M-x customize-variable org-link-parameters=

 The default function called is =browse-url=, which opens a mail
 composition buffer within Emacs. The type of buffer opened by
-browse-url depends on the setting of the variable =mail-user-agent=.
+=browse-url= depends on the setting of the variable =mail-user-agent=.
 Thus, if you want to ensure that mailto links use Gnus to open a
 message buffer, you could add the following to your =.emacs=:

@@ -1941,6 +1941,18 @@ message buffer, you could add the following to 
your =.emacs=:

 (setq mail-user-agent 'gnus-user-agent)
 #+end_src

+You can also change the function used to a different one.  For
+example, the following function (on MacOS) opens =mailto:= links in
+the =MailMate= program:
+
+#+begin_src elisp
+("mailto" :follow
+  (lambda
+(path)
+(shell-command
+ (format "open -a MailMate 'mailto:%s'" path
+#+end_src
+
 ** Can I use CamelCase links?
:PROPERTIES:
:CUSTOM_ID: CamelCase-links
--
2.31.1