unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
@ 2022-11-21 11:45 Gabriel
  2022-11-21 13:52 ` Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel @ 2022-11-21 11:45 UTC (permalink / raw)
  To: 59443

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

Description:

When `goto-address-mode' is enabled, it's not possible to make "C-c RET"
(`goto-address-at-point') open an URL with
`browse-url-secondary-browser-function`.

Steps:
1) emacs -Q (master "6b0179f7908c658342d1e642e5444e3d2e1cd997")

2) eval
(progn
  (require 'browse-url)
  (setopt browse-url-browser-function           #'eww-browse-url
          browse-url-secondary-browser-function #'browse-url-default-browser)
  (scratch-buffer)
  (goto-address-mode))

3) Insert "https://www.gnu.org/software/emacs/" in the *scratch* buffer

4) Put point at URL and execute C-c RET (`goto-address-at-point')

Result: `browse-url-browser-function' opens the URL with the default
browser function.  It's not possible to specify the use of the
`browse-url-secondary-browser-function'.

A proposed patch is attached.  The prefix argument will not affect the
argument CONTINUE of `compose-email'.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-goto-address-at-point-to-use-secondary-browser.patch --]
[-- Type: text/x-diff, Size: 2446 bytes --]

From bfcd2ccb83a94fa1ba99db84cf55e88584fc25d1 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Mon, 21 Nov 2022 08:08:52 -0300
Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser

* lisp/net/dictionary.el (goto-address-at-point): Call
  `browse-url-button-open-url', so a prefix argument uses
  `browse-url-secondary-browser-function'.
---
 lisp/net/goto-addr.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 86cf98004b..86b8fed362 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -222,25 +222,28 @@ goto-address-fontify-region
 
 ;;;###autoload
 (defun goto-address-at-point (&optional event)
-  "Send to the e-mail address or load the URL at point.
-Send mail to address at point.  See documentation for
-`goto-address-find-address-at-point'.  If no address is found
-there, then load the URL at or before point."
+  "Compose a new message to the e-mail address or browse the URL at
+point.
+
+If no e-mail address is found at point, use the URL at or before
+point.  See `goto-address-find-address-at-point'.
+
+With prefix argument, use the secondary browser to open the URL.
+See `browse-url-button-open-url'."
   (interactive (list last-input-event))
   (save-excursion
     (if event (posn-set-point (event-end event)))
     (let ((address (save-excursion (goto-address-find-address-at-point))))
       (if (and address
-	       (save-excursion
-		 (goto-char (previous-single-char-property-change
-			     (point) 'goto-address nil
-			     (line-beginning-position)))
-		 (not (looking-at goto-address-url-regexp))))
-	  (compose-mail address)
-	(let ((url (browse-url-url-at-point)))
-	  (if url
-	      (browse-url url)
-	    (error "No e-mail address or URL found")))))))
+               (save-excursion
+                 (goto-char (previous-single-char-property-change
+                             (point) 'goto-address nil
+                             (line-beginning-position)))
+                 (not (looking-at goto-address-url-regexp))))
+          (compose-mail address)
+        (if-let ((url (browse-url-url-at-point)))
+            (browse-url-button-open-url url)
+          (error "No e-mail address or URL found"))))))
 
 (defun goto-address-find-address-at-point ()
   "Find e-mail address around or before point.
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


---
Gabriel

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

* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
  2022-11-21 11:45 bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser Gabriel
@ 2022-11-21 13:52 ` Stefan Kangas
  2022-11-21 15:03   ` Gabriel
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2022-11-21 13:52 UTC (permalink / raw)
  To: Gabriel, 59443

I didn't really study the patch or the issue, but here are two nits.

Gabriel <gabriel376@hotmail.com> writes:

> * lisp/net/dictionary.el (goto-address-at-point): Call
>   `browse-url-button-open-url', so a prefix argument uses
>   `browse-url-secondary-browser-function'.
  ^^

We do not indent the commit message like this.  It should start at
column 0.


>  ;;;###autoload
>  (defun goto-address-at-point (&optional event)
> -  "Send to the e-mail address or load the URL at point.
> -Send mail to address at point.  See documentation for
> -`goto-address-find-address-at-point'.  If no address is found
> -there, then load the URL at or before point."
> +  "Compose a new message to the e-mail address or browse the URL at
> +point.

The first line of a docstring should be a complete sentence (for
e.g. eldoc and apropos).





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

* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
  2022-11-21 13:52 ` Stefan Kangas
@ 2022-11-21 15:03   ` Gabriel
  2022-11-21 16:51     ` Visuwesh
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel @ 2022-11-21 15:03 UTC (permalink / raw)
  To: 59443

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

Stefan Kangas <stefankangas@gmail.com> writes:

> I didn't really study the patch or the issue, but here are two nits.
>
> Gabriel <gabriel376@hotmail.com> writes:
>
>> * lisp/net/dictionary.el (goto-address-at-point): Call
>>   `browse-url-button-open-url', so a prefix argument uses
>>   `browse-url-secondary-browser-function'.
>   ^^
>
> We do not indent the commit message like this.  It should start at
> column 0.
>
>
>>  ;;;###autoload
>>  (defun goto-address-at-point (&optional event)
>> -  "Send to the e-mail address or load the URL at point.
>> -Send mail to address at point.  See documentation for
>> -`goto-address-find-address-at-point'.  If no address is found
>> -there, then load the URL at or before point."
>> +  "Compose a new message to the e-mail address or browse the URL at
>> +point.
>
> The first line of a docstring should be a complete sentence (for
> e.g. eldoc and apropos).

Thanks for the quick review, Stefan.

Please find attached an updated patch.  I fixed the commit message
indent and rephrased the first line of docstring to be a complete
sentence (based on the docstring's of `compose-mail' and
`browse-url-button-open-url').


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-goto-address-at-point-to-use-secondary-browser.patch --]
[-- Type: text/x-diff, Size: 2453 bytes --]

From 2151f92bf5d07106d7f322ea69bfc745b0bf1d28 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Mon, 21 Nov 2022 08:08:52 -0300
Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser

* lisp/net/dictionary.el (goto-address-at-point): Call
`browse-url-button-open-url', so a prefix argument uses
`browse-url-secondary-browser-function'.
---
 lisp/net/goto-addr.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 86cf98004b..03e14c9268 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -222,25 +222,28 @@ goto-address-fontify-region
 
 ;;;###autoload
 (defun goto-address-at-point (&optional event)
-  "Send to the e-mail address or load the URL at point.
-Send mail to address at point.  See documentation for
-`goto-address-find-address-at-point'.  If no address is found
-there, then load the URL at or before point."
+  "Start composing a new message to the e-mail address at point or
+open URL at point.
+
+If no e-mail address is found at point, use the URL at or before
+point.  See `goto-address-find-address-at-point'.
+
+With prefix argument, use the secondary browser to open the URL.
+See `browse-url-button-open-url'."
   (interactive (list last-input-event))
   (save-excursion
     (if event (posn-set-point (event-end event)))
     (let ((address (save-excursion (goto-address-find-address-at-point))))
       (if (and address
-	       (save-excursion
-		 (goto-char (previous-single-char-property-change
-			     (point) 'goto-address nil
-			     (line-beginning-position)))
-		 (not (looking-at goto-address-url-regexp))))
-	  (compose-mail address)
-	(let ((url (browse-url-url-at-point)))
-	  (if url
-	      (browse-url url)
-	    (error "No e-mail address or URL found")))))))
+               (save-excursion
+                 (goto-char (previous-single-char-property-change
+                             (point) 'goto-address nil
+                             (line-beginning-position)))
+                 (not (looking-at goto-address-url-regexp))))
+          (compose-mail address)
+        (if-let ((url (browse-url-url-at-point)))
+            (browse-url-button-open-url url)
+          (error "No e-mail address or URL found"))))))
 
 (defun goto-address-find-address-at-point ()
   "Find e-mail address around or before point.
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


---
Gabriel

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

* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
  2022-11-21 15:03   ` Gabriel
@ 2022-11-21 16:51     ` Visuwesh
  2022-11-21 18:31       ` Gabriel
  0 siblings, 1 reply; 6+ messages in thread
From: Visuwesh @ 2022-11-21 16:51 UTC (permalink / raw)
  To: Gabriel; +Cc: 59443

[திங்கள் நவம்பர் 21, 2022] Gabriel wrote:

> [...]
> From 2151f92bf5d07106d7f322ea69bfc745b0bf1d28 Mon Sep 17 00:00:00 2001
> From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
> Date: Mon, 21 Nov 2022 08:08:52 -0300
> Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser
>
> * lisp/net/dictionary.el (goto-address-at-point): Call
    ^^^^^^^^^^^^^^^^^^^^^^
Hmm, the patch touches lisp/net/goto-addr.el but the commit message
refers to another file.

> `browse-url-button-open-url', so a prefix argument uses
> `browse-url-secondary-browser-function'.
> ---
>  lisp/net/goto-addr.el | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
> index 86cf98004b..03e14c9268 100644
> --- a/lisp/net/goto-addr.el
> +++ b/lisp/net/goto-addr.el
> [...]





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

* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
  2022-11-21 16:51     ` Visuwesh
@ 2022-11-21 18:31       ` Gabriel
  2022-11-25  0:34         ` Stefan Kangas
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel @ 2022-11-21 18:31 UTC (permalink / raw)
  To: 59443

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

Visuwesh <visuweshm@gmail.com> writes:

> [திங்கள் நவம்பர் 21, 2022] Gabriel wrote:
>
>> [...]
>> From 2151f92bf5d07106d7f322ea69bfc745b0bf1d28 Mon Sep 17 00:00:00 2001
>> From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
>> Date: Mon, 21 Nov 2022 08:08:52 -0300
>> Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser
>>
>> * lisp/net/dictionary.el (goto-address-at-point): Call
>     ^^^^^^^^^^^^^^^^^^^^^^
> Hmm, the patch touches lisp/net/goto-addr.el but the commit message
> refers to another file.
>

Thanks, fixed.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-goto-address-at-point-to-use-secondary-browser.patch --]
[-- Type: text/x-diff, Size: 2453 bytes --]

>From 2151f92bf5d07106d7f322ea69bfc745b0bf1d28 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
Date: Mon, 21 Nov 2022 08:08:52 -0300
Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser

* lisp/net/goto-addr.el (goto-address-at-point): Call
`browse-url-button-open-url', so a prefix argument uses
`browse-url-secondary-browser-function'.
---
 lisp/net/goto-addr.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index 86cf98004b..03e14c9268 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -222,25 +222,28 @@ goto-address-fontify-region
 
 ;;;###autoload
 (defun goto-address-at-point (&optional event)
-  "Send to the e-mail address or load the URL at point.
-Send mail to address at point.  See documentation for
-`goto-address-find-address-at-point'.  If no address is found
-there, then load the URL at or before point."
+  "Start composing a new message to the e-mail address at point or
+open URL at point.
+
+If no e-mail address is found at point, use the URL at or before
+point.  See `goto-address-find-address-at-point'.
+
+With prefix argument, use the secondary browser to open the URL.
+See `browse-url-button-open-url'."
   (interactive (list last-input-event))
   (save-excursion
     (if event (posn-set-point (event-end event)))
     (let ((address (save-excursion (goto-address-find-address-at-point))))
       (if (and address
-	       (save-excursion
-		 (goto-char (previous-single-char-property-change
-			     (point) 'goto-address nil
-			     (line-beginning-position)))
-		 (not (looking-at goto-address-url-regexp))))
-	  (compose-mail address)
-	(let ((url (browse-url-url-at-point)))
-	  (if url
-	      (browse-url url)
-	    (error "No e-mail address or URL found")))))))
+               (save-excursion
+                 (goto-char (previous-single-char-property-change
+                             (point) 'goto-address nil
+                             (line-beginning-position)))
+                 (not (looking-at goto-address-url-regexp))))
+          (compose-mail address)
+        (if-let ((url (browse-url-url-at-point)))
+            (browse-url-button-open-url url)
+          (error "No e-mail address or URL found"))))))
 
 (defun goto-address-find-address-at-point ()
   "Find e-mail address around or before point.
-- 
2.34.1


[-- Attachment #3: Type: text/plain, Size: 13 bytes --]


---
Gabriel

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

* bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser
  2022-11-21 18:31       ` Gabriel
@ 2022-11-25  0:34         ` Stefan Kangas
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2022-11-25  0:34 UTC (permalink / raw)
  To: Gabriel; +Cc: 59443

close 59443 29.1
thanks

Gabriel <gabriel376@hotmail.com> writes:

> Visuwesh <visuweshm@gmail.com> writes:
>
>> [திங்கள் நவம்பர் 21, 2022] Gabriel wrote:
>>
>>> [...]
>>> From 2151f92bf5d07106d7f322ea69bfc745b0bf1d28 Mon Sep 17 00:00:00 2001
>>> From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
>>> Date: Mon, 21 Nov 2022 08:08:52 -0300
>>> Subject: [PATCH 1/1] Allow goto-address-at-point to use secondary browser
>>>
>>> * lisp/net/dictionary.el (goto-address-at-point): Call
>>     ^^^^^^^^^^^^^^^^^^^^^^
>> Hmm, the patch touches lisp/net/goto-addr.el but the commit message
>> refers to another file.
>>
>
> Thanks, fixed.

Thanks, the commit looks good to me so I pushed it to master (commit
29a262bfa7).  See also the documentation fixes I made in a followup
patch (commit 60354fcf49).





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

end of thread, other threads:[~2022-11-25  0:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 11:45 bug#59443: 29.0.50; [PATCH] Allow goto-address-at-point to use secondary browser Gabriel
2022-11-21 13:52 ` Stefan Kangas
2022-11-21 15:03   ` Gabriel
2022-11-21 16:51     ` Visuwesh
2022-11-21 18:31       ` Gabriel
2022-11-25  0:34         ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).