* bug#74781: [PATCH] Add `browse-url-qutebrowser'
@ 2024-12-11 7:04 Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 8:27 ` Robert Pluim
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 7:04 UTC (permalink / raw)
To: 74781
[-- Attachment #1: Type: text/plain, Size: 205 bytes --]
Tags: patch
The browser launcher supports the NEW-WINDOW argument and
`browse-url-qutebrowser-new-window-is-tab' to open tabs. Furthermore
opening new URLs is speed up via Unix socket IPC if available.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-browse-url-qutebrowser.patch --]
[-- Type: text/patch, Size: 4565 bytes --]
From ea24ef81a4a8551a8212582a65dd4aa685c9c648 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
Date: Wed, 11 Dec 2024 07:36:16 +0100
Subject: [PATCH] Add `browse-url-qutebrowser'
The browser launcher supports the NEW-WINDOW argument and
`browse-url-qutebrowser-new-window-is-tab' to open tabs.
Furthermore opening new URLs is speed up via Unix socket IPC if
available.
* lisp/net/browse-url.el (browse-url-qutebrowser-send): Function
to send command to Qutebrowser via IPC.
(browse-url-qutebrowser): New browser launcher. Use
`browse-url-qutebrowser-send'.
(browse-url-qutebrowser-program, browse-url-qutebrowser-arguments,
browse-url-qutebrowser-new-window-is-tab): New customizables.
---
lisp/net/browse-url.el | 68 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 8ec025d017b..3b6833715f4 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -342,6 +342,14 @@ browse-url-epiphany-startup-arguments
`browse-url' is loaded."
:type '(repeat (string :tag "Argument")))
+(defcustom browse-url-qutebrowser-program "qutebrowser"
+ "The name by which to invoke Qutebrowser."
+ :type 'string)
+
+(defcustom browse-url-qutebrowser-arguments nil
+ "A list of strings to pass to Qutebrowser when it starts up."
+ :type '(repeat (string :tag "Argument")))
+
(defcustom browse-url-webpositive-program "WebPositive"
"The name by which to invoke WebPositive."
:type 'string
@@ -387,6 +395,12 @@ browse-url-epiphany-new-window-is-tab
`browse-url-epiphany' is asked to open it in a new window."
:type 'boolean)
+(defcustom browse-url-qutebrowser-new-window-is-tab nil
+ "Whether to open up new windows in a tab or a new window.
+If non-nil, then open the URL in a new tab rather than a new window if
+`browse-url-qutebrowser' is asked to open it in a new window."
+ :type 'boolean)
+
(defcustom browse-url-new-window-flag nil
"Non-nil means always open a new browser window with appropriate browsers.
Passing an interactive argument to \\[browse-url], or specific browser
@@ -1294,6 +1308,60 @@ browse-url-epiphany-sentinel
browse-url-epiphany-program
(append browse-url-epiphany-startup-arguments (list url))))))
+(defun browse-url-qutebrowser-send (cmd)
+ "Send CMD to Qutebrowser via IPC."
+ (let* ((dir (getenv "XDG_RUNTIME_DIR"))
+ (sock (and dir (expand-file-name
+ (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
+ dir))))
+ (unless (file-exists-p sock)
+ (error "No Qutebrowser IPC socket found"))
+ (let ((proc
+ (make-network-process
+ :name "qutebrowser"
+ :family 'local
+ :service sock
+ :coding 'utf-8)))
+ (unwind-protect
+ (process-send-string
+ proc
+ (concat
+ (json-serialize `( :args [,cmd]
+ :target_arg :null
+ :protocol_version 1))
+ "\n"))
+ (delete-process proc)))))
+
+(defun browse-url-qutebrowser (url &optional new-window)
+ "Ask the Qutebrowser WWW browser to load URL.
+Default to the URL around or before point.
+
+When called interactively, if variable `browse-url-new-window-flag' is
+non-nil, load the document in a new Qutebrowser window, otherwise use a
+random existing one. A non-nil interactive prefix argument reverses
+the effect of `browse-url-new-window-flag'.
+
+If `browse-url-qutebrowser-new-window-is-tab' is non-nil, then whenever a
+document would otherwise be loaded in a new window, it is loaded in a
+new tab in an existing window instead.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of `browse-url-new-window-flag'."
+ (interactive (browse-url-interactive-arg "URL: "))
+ (let ((cmd (concat ":open "
+ (and (browse-url-maybe-new-window new-window)
+ (if browse-url-qutebrowser-new-window-is-tab
+ "-t " "-w "))
+ (browse-url-encode-url url))))
+ (condition-case nil
+ (browse-url-qutebrowser-send cmd)
+ (error
+ (apply #'start-process (concat "qutebrowser " url) nil
+ browse-url-qutebrowser-program
+ (append browse-url-qutebrowser-arguments (list cmd)))))))
+
+(function-put 'browse-url-qutebrowser 'browse-url-browser-kind 'external)
+
(defvar url-handler-regexp)
;;;###autoload
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 7:04 bug#74781: [PATCH] Add `browse-url-qutebrowser' Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 8:27 ` Robert Pluim
2024-12-11 9:07 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:40 ` Eli Zaretskii
2024-12-14 12:50 ` bug#74781: Status: " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2 siblings, 1 reply; 16+ messages in thread
From: Robert Pluim @ 2024-12-11 8:27 UTC (permalink / raw)
To: 74781; +Cc: Daniel Mendler
>>>>> On Wed, 11 Dec 2024 08:04:29 +0100, Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:
Daniel> +(defcustom browse-url-qutebrowser-program "qutebrowser"
Daniel> + "The name by which to invoke Qutebrowser."
Daniel> + :type 'string)
Daniel> +
Daniel> +(defcustom browse-url-qutebrowser-arguments nil
Daniel> + "A list of strings to pass to Qutebrowser when it starts up."
Daniel> + :type '(repeat (string :tag "Argument")))
Daniel> +
:version tags please
Daniel> (defcustom browse-url-webpositive-program "WebPositive"
Daniel> "The name by which to invoke WebPositive."
Daniel> :type 'string
Daniel> @@ -387,6 +395,12 @@ browse-url-epiphany-new-window-is-tab
Daniel> `browse-url-epiphany' is asked to open it in a new window."
Daniel> :type 'boolean)
Daniel> +(defcustom browse-url-qutebrowser-new-window-is-tab nil
Daniel> + "Whether to open up new windows in a tab or a new window.
Daniel> +If non-nil, then open the URL in a new tab rather than a new window if
Daniel> +`browse-url-qutebrowser' is asked to open it in a new window."
Daniel> + :type 'boolean)
Daniel> +
And here
Daniel> (defcustom browse-url-new-window-flag nil
Daniel> "Non-nil means always open a new browser window with appropriate browsers.
Daniel> Passing an interactive argument to \\[browse-url], or specific browser
Daniel> @@ -1294,6 +1308,60 @@ browse-url-epiphany-sentinel
Daniel> browse-url-epiphany-program
Daniel> (append browse-url-epiphany-startup-arguments (list url))))))
Daniel> +(defun browse-url-qutebrowser-send (cmd)
Daniel> + "Send CMD to Qutebrowser via IPC."
Daniel> + (let* ((dir (getenv "XDG_RUNTIME_DIR"))
We have `xdg-runtime-dir' in xdg.el
Daniel> + (sock (and dir (expand-file-name
Daniel> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
Daniel> + dir))))
Daniel> + (unless (file-exists-p sock)
Daniel> + (error "No Qutebrowser IPC socket found"))
Daniel> + (let ((proc
Daniel> + (make-network-process
Daniel> + :name "qutebrowser"
Daniel> + :family 'local
Daniel> + :service sock
Daniel> + :coding 'utf-8)))
Daniel> + (unwind-protect
Daniel> + (process-send-string
Daniel> + proc
Daniel> + (concat
Daniel> + (json-serialize `( :args [,cmd]
Daniel> + :target_arg :null
Daniel> + :protocol_version 1))
Daniel> + "\n"))
Daniel> + (delete-process proc)))))
Daniel> +
Perhaps Iʼm being paranoid, but maybe you should check the status of
`proc' before sending it a string.
Robert
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 8:27 ` Robert Pluim
@ 2024-12-11 9:07 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 9:58 ` Robert Pluim
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 9:07 UTC (permalink / raw)
To: Robert Pluim; +Cc: 74781
Hi Robert,
thank you for looking at the patch. I have a few questions.
> Daniel> +(defcustom browse-url-qutebrowser-program "qutebrowser"
> Daniel> + "The name by which to invoke Qutebrowser."
> Daniel> + :type 'string)
> Daniel> +
> Daniel> +(defcustom browse-url-qutebrowser-arguments nil
> Daniel> + "A list of strings to pass to Qutebrowser when it starts up."
> Daniel> + :type '(repeat (string :tag "Argument")))
> Daniel> +
>
> :version tags please
Other similar variables have been added recently and lack the version
tags. I didn't add the tags for consistency with the other variables. I
wonder if the Emacs help system does recognize automatically when
variables got added?
> Daniel> (defcustom browse-url-new-window-flag nil
> Daniel> "Non-nil means always open a new browser window with appropriate browsers.
> Daniel> Passing an interactive argument to \\[browse-url], or specific browser
> Daniel> @@ -1294,6 +1308,60 @@ browse-url-epiphany-sentinel
> Daniel> browse-url-epiphany-program
> Daniel> (append browse-url-epiphany-startup-arguments (list url))))))
>
> Daniel> +(defun browse-url-qutebrowser-send (cmd)
> Daniel> + "Send CMD to Qutebrowser via IPC."
> Daniel> + (let* ((dir (getenv "XDG_RUNTIME_DIR"))
>
> We have `xdg-runtime-dir' in xdg.el
The goal was to avoid loading `xdg.el' unnecessarily for this trivial
function, which is just a wrapper around `getenv'. Do you suggest to use
`declare-function' and require xdg inside `browse-url-qutebrowser-send'?
> Daniel> + (sock (and dir (expand-file-name
> Daniel> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
> Daniel> + dir))))
> Daniel> + (unless (file-exists-p sock)
> Daniel> + (error "No Qutebrowser IPC socket found"))
> Daniel> + (let ((proc
> Daniel> + (make-network-process
> Daniel> + :name "qutebrowser"
> Daniel> + :family 'local
> Daniel> + :service sock
> Daniel> + :coding 'utf-8)))
> Daniel> + (unwind-protect
> Daniel> + (process-send-string
> Daniel> + proc
> Daniel> + (concat
> Daniel> + (json-serialize `( :args [,cmd]
> Daniel> + :target_arg :null
> Daniel> + :protocol_version 1))
> Daniel> + "\n"))
> Daniel> + (delete-process proc)))))
> Daniel> +
>
> Perhaps Iʼm being paranoid, but maybe you should check the status of
> `proc' before sending it a string.
`process-send-string' throwns an error if opening the file failed, so a
status check won't be beneficial. Also note that `make-network-process'
fails if opening the socket file fails. Thanks again.
Daniel
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 9:07 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 9:58 ` Robert Pluim
2024-12-11 10:45 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 16+ messages in thread
From: Robert Pluim @ 2024-12-11 9:58 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74781
>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler <mail@daniel-mendler.de> said:
Daniel> Hi Robert,
Daniel> thank you for looking at the patch. I have a few questions.
Daniel> +(defcustom browse-url-qutebrowser-program "qutebrowser"
Daniel> + "The name by which to invoke Qutebrowser."
Daniel> + :type 'string)
Daniel> +
Daniel> +(defcustom browse-url-qutebrowser-arguments nil
Daniel> + "A list of strings to pass to Qutebrowser when it starts up."
Daniel> + :type '(repeat (string :tag "Argument")))
Daniel> +
>>
>> :version tags please
Daniel> Other similar variables have been added recently and lack the version
Daniel> tags. I didn't add the tags for consistency with the other variables. I
Daniel> wonder if the Emacs help system does recognize automatically when
Daniel> variables got added?
Then those should be fixed as well.
The emacs help system applies heuristics which are not always
accurate, and donʼt always return an answer, hence the version tags.
Daniel> (defcustom browse-url-new-window-flag nil
Daniel> "Non-nil means always open a new browser window with appropriate browsers.
Daniel> Passing an interactive argument to \\[browse-url], or specific browser
Daniel> @@ -1294,6 +1308,60 @@ browse-url-epiphany-sentinel
Daniel> browse-url-epiphany-program
Daniel> (append browse-url-epiphany-startup-arguments (list url))))))
>>
Daniel> +(defun browse-url-qutebrowser-send (cmd)
Daniel> + "Send CMD to Qutebrowser via IPC."
Daniel> + (let* ((dir (getenv "XDG_RUNTIME_DIR"))
>>
>> We have `xdg-runtime-dir' in xdg.el
Daniel> The goal was to avoid loading `xdg.el' unnecessarily for this trivial
Daniel> function, which is just a wrapper around `getenv'. Do you suggest to use
Daniel> `declare-function' and require xdg inside `browse-url-qutebrowser-send'?
That would work.
>> Perhaps Iʼm being paranoid, but maybe you should check the status of
>> `proc' before sending it a string.
Daniel> `process-send-string' throwns an error if opening the file failed, so a
Daniel> status check won't be beneficial. Also note that `make-network-process'
Daniel> fails if opening the socket file fails. Thanks again.
OK, so I was too paranoid 😀
Robert
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 9:58 ` Robert Pluim
@ 2024-12-11 10:45 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 15:32 ` Eli Zaretskii
0 siblings, 2 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 10:45 UTC (permalink / raw)
To: Robert Pluim; +Cc: 74781
[-- Attachment #1: Type: text/plain, Size: 856 bytes --]
Robert Pluim <rpluim@gmail.com> writes:
>>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler <mail@daniel-mendler.de> said:
> The emacs help system applies heuristics which are not always
> accurate, and donʼt always return an answer, hence the version tags.
Thanks, I added the version tags. See the updated patch.
> >> We have `xdg-runtime-dir' in xdg.el
>
> Daniel> The goal was to avoid loading `xdg.el' unnecessarily for this trivial
> Daniel> function, which is just a wrapper around `getenv'. Do you suggest to use
> Daniel> `declare-function' and require xdg inside `browse-url-qutebrowser-send'?
>
> That would work.
I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead of
replacing it by this:
(declare-function xdg-runtime-dir "xdg")
(require 'xdg)
(xdg-runtime-dir)
Daniel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-browse-url-qutebrowser.patch --]
[-- Type: text/x-diff, Size: 4622 bytes --]
From 753ee0b033a34a556cdef8c7d2009b423e115fb0 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
Date: Wed, 11 Dec 2024 07:36:16 +0100
Subject: [PATCH] Add `browse-url-qutebrowser'
The browser launcher supports the NEW-WINDOW argument and
`browse-url-qutebrowser-new-window-is-tab' to open tabs.
Furthermore opening new URLs is speed up via Unix socket IPC if
available.
* lisp/net/browse-url.el (browse-url-qutebrowser-send): Function
to send command to Qutebrowser via IPC.
(browse-url-qutebrowser): New browser launcher. Use
`browse-url-qutebrowser-send'.
(browse-url-qutebrowser-program, browse-url-qutebrowser-arguments,
browse-url-qutebrowser-new-window-is-tab): New customizables.
---
lisp/net/browse-url.el | 71 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 8ec025d017b..0533810dae2 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -342,6 +342,16 @@ browse-url-epiphany-startup-arguments
`browse-url' is loaded."
:type '(repeat (string :tag "Argument")))
+(defcustom browse-url-qutebrowser-program "qutebrowser"
+ "The name by which to invoke Qutebrowser."
+ :type 'string
+ :version "31.1")
+
+(defcustom browse-url-qutebrowser-arguments nil
+ "A list of strings to pass to Qutebrowser when it starts up."
+ :type '(repeat (string :tag "Argument"))
+ :version "31.1")
+
(defcustom browse-url-webpositive-program "WebPositive"
"The name by which to invoke WebPositive."
:type 'string
@@ -387,6 +397,13 @@ browse-url-epiphany-new-window-is-tab
`browse-url-epiphany' is asked to open it in a new window."
:type 'boolean)
+(defcustom browse-url-qutebrowser-new-window-is-tab nil
+ "Whether to open up new windows in a tab or a new window.
+If non-nil, then open the URL in a new tab rather than a new window if
+`browse-url-qutebrowser' is asked to open it in a new window."
+ :type 'boolean
+ :version "31.1")
+
(defcustom browse-url-new-window-flag nil
"Non-nil means always open a new browser window with appropriate browsers.
Passing an interactive argument to \\[browse-url], or specific browser
@@ -1294,6 +1311,60 @@ browse-url-epiphany-sentinel
browse-url-epiphany-program
(append browse-url-epiphany-startup-arguments (list url))))))
+(defun browse-url-qutebrowser-send (cmd)
+ "Send CMD to Qutebrowser via IPC."
+ (let* ((dir (getenv "XDG_RUNTIME_DIR"))
+ (sock (and dir (expand-file-name
+ (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
+ dir))))
+ (unless (file-exists-p sock)
+ (error "No Qutebrowser IPC socket found"))
+ (let ((proc
+ (make-network-process
+ :name "qutebrowser"
+ :family 'local
+ :service sock
+ :coding 'utf-8)))
+ (unwind-protect
+ (process-send-string
+ proc
+ (concat
+ (json-serialize `( :args [,cmd]
+ :target_arg :null
+ :protocol_version 1))
+ "\n"))
+ (delete-process proc)))))
+
+(defun browse-url-qutebrowser (url &optional new-window)
+ "Ask the Qutebrowser WWW browser to load URL.
+Default to the URL around or before point.
+
+When called interactively, if variable `browse-url-new-window-flag' is
+non-nil, load the document in a new Qutebrowser window, otherwise use a
+random existing one. A non-nil interactive prefix argument reverses
+the effect of `browse-url-new-window-flag'.
+
+If `browse-url-qutebrowser-new-window-is-tab' is non-nil, then whenever a
+document would otherwise be loaded in a new window, it is loaded in a
+new tab in an existing window instead.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of `browse-url-new-window-flag'."
+ (interactive (browse-url-interactive-arg "URL: "))
+ (let ((cmd (concat ":open "
+ (and (browse-url-maybe-new-window new-window)
+ (if browse-url-qutebrowser-new-window-is-tab
+ "-t " "-w "))
+ (browse-url-encode-url url))))
+ (condition-case nil
+ (browse-url-qutebrowser-send cmd)
+ (error
+ (apply #'start-process (concat "qutebrowser " url) nil
+ browse-url-qutebrowser-program
+ (append browse-url-qutebrowser-arguments (list cmd)))))))
+
+(function-put 'browse-url-qutebrowser 'browse-url-browser-kind 'external)
+
(defvar url-handler-regexp)
;;;###autoload
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 10:45 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 14:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:38 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 15:32 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 14:14 UTC (permalink / raw)
To: 74781; +Cc: mail, rpluim
Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> writes:
> Robert Pluim <rpluim@gmail.com> writes:
>
>>>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler <mail@daniel-mendler.de> said:
>> The emacs help system applies heuristics which are not always
>> accurate, and donʼt always return an answer, hence the version tags.
>
> Thanks, I added the version tags. See the updated patch.
>
>> >> We have `xdg-runtime-dir' in xdg.el
>>
>> Daniel> The goal was to avoid loading `xdg.el' unnecessarily for this trivial
>> Daniel> function, which is just a wrapper around `getenv'. Do you suggest to use
>> Daniel> `declare-function' and require xdg inside `browse-url-qutebrowser-send'?
>>
>> That would work.
>
> I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead
> of replacing it by this:
>
> (declare-function xdg-runtime-dir "xdg")
> (require 'xdg)
These are only required because you load a new dependency.
Further these functions can take care of later eventualities if needed,
e.g. such as handling when a xdg variable isn't set.
Also using these functions makes the code easier to read as you can
follow the code down further to the documentation.
> (xdg-runtime-dir)
>
> Daniel
>
> From 753ee0b033a34a556cdef8c7d2009b423e115fb0 Mon Sep 17 00:00:00 2001
> From: Daniel Mendler <mail@daniel-mendler.de>
> Date: Wed, 11 Dec 2024 07:36:16 +0100
> Subject: [PATCH] Add `browse-url-qutebrowser'
>
> The browser launcher supports the NEW-WINDOW argument and
> `browse-url-qutebrowser-new-window-is-tab' to open tabs.
> Furthermore opening new URLs is speed up via Unix socket IPC if
> available.
>
> * lisp/net/browse-url.el (browse-url-qutebrowser-send): Function
> to send command to Qutebrowser via IPC.
> (browse-url-qutebrowser): New browser launcher. Use
> `browse-url-qutebrowser-send'.
> (browse-url-qutebrowser-program, browse-url-qutebrowser-arguments,
> browse-url-qutebrowser-new-window-is-tab): New customizables.
> ---
> lisp/net/browse-url.el | 71 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 71 insertions(+)
>
> diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
> index 8ec025d017b..0533810dae2 100644
> --- a/lisp/net/browse-url.el
> +++ b/lisp/net/browse-url.el
> @@ -342,6 +342,16 @@ browse-url-epiphany-startup-arguments
> `browse-url' is loaded."
> :type '(repeat (string :tag "Argument")))
>
> +(defcustom browse-url-qutebrowser-program "qutebrowser"
> + "The name by which to invoke Qutebrowser."
> + :type 'string
> + :version "31.1")
> +
> +(defcustom browse-url-qutebrowser-arguments nil
> + "A list of strings to pass to Qutebrowser when it starts up."
> + :type '(repeat (string :tag "Argument"))
> + :version "31.1")
> +
> (defcustom browse-url-webpositive-program "WebPositive"
> "The name by which to invoke WebPositive."
> :type 'string
> @@ -387,6 +397,13 @@ browse-url-epiphany-new-window-is-tab
> `browse-url-epiphany' is asked to open it in a new window."
> :type 'boolean)
>
> +(defcustom browse-url-qutebrowser-new-window-is-tab nil
> + "Whether to open up new windows in a tab or a new window.
> +If non-nil, then open the URL in a new tab rather than a new window if
> +`browse-url-qutebrowser' is asked to open it in a new window."
> + :type 'boolean
> + :version "31.1")
> +
> (defcustom browse-url-new-window-flag nil
> "Non-nil means always open a new browser window with appropriate browsers.
> Passing an interactive argument to \\[browse-url], or specific browser
> @@ -1294,6 +1311,60 @@ browse-url-epiphany-sentinel
> browse-url-epiphany-program
> (append browse-url-epiphany-startup-arguments (list url))))))
>
> +(defun browse-url-qutebrowser-send (cmd)
> + "Send CMD to Qutebrowser via IPC."
> + (let* ((dir (getenv "XDG_RUNTIME_DIR"))
> + (sock (and dir (expand-file-name
> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
> + dir))))
> + (unless (file-exists-p sock)
> + (error "No Qutebrowser IPC socket found"))
> + (let ((proc
> + (make-network-process
> + :name "qutebrowser"
> + :family 'local
> + :service sock
> + :coding 'utf-8)))
> + (unwind-protect
> + (process-send-string
> + proc
> + (concat
> + (json-serialize `( :args [,cmd]
> + :target_arg :null
> + :protocol_version 1))
> + "\n"))
> + (delete-process proc)))))
> +
> +(defun browse-url-qutebrowser (url &optional new-window)
> + "Ask the Qutebrowser WWW browser to load URL.
> +Default to the URL around or before point.
> +
> +When called interactively, if variable `browse-url-new-window-flag' is
> +non-nil, load the document in a new Qutebrowser window, otherwise use a
> +random existing one. A non-nil interactive prefix argument reverses
> +the effect of `browse-url-new-window-flag'.
> +
> +If `browse-url-qutebrowser-new-window-is-tab' is non-nil, then whenever a
> +document would otherwise be loaded in a new window, it is loaded in a
> +new tab in an existing window instead.
> +
> +When called non-interactively, optional second argument NEW-WINDOW is
> +used instead of `browse-url-new-window-flag'."
> + (interactive (browse-url-interactive-arg "URL: "))
> + (let ((cmd (concat ":open "
> + (and (browse-url-maybe-new-window new-window)
> + (if browse-url-qutebrowser-new-window-is-tab
> + "-t " "-w "))
> + (browse-url-encode-url url))))
> + (condition-case nil
> + (browse-url-qutebrowser-send cmd)
> + (error
> + (apply #'start-process (concat "qutebrowser " url) nil
> + browse-url-qutebrowser-program
> + (append browse-url-qutebrowser-arguments (list cmd)))))))
> +
> +(function-put 'browse-url-qutebrowser 'browse-url-browser-kind 'external)
> +
> (defvar url-handler-regexp)
>
> ;;;###autoload
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 14:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 14:38 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 16:16 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 14:38 UTC (permalink / raw)
To: Björn Bidar; +Cc: 74781, rpluim
Björn Bidar <bjorn.bidar@thaodan.de> writes:
> Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs@gnu.org> writes:
>
>> Robert Pluim <rpluim@gmail.com> writes:
>>
>>>>>>>> On Wed, 11 Dec 2024 10:07:08 +0100, Daniel Mendler <mail@daniel-mendler.de> said:
>>> The emacs help system applies heuristics which are not always
>>> accurate, and donʼt always return an answer, hence the version tags.
>>
>> Thanks, I added the version tags. See the updated patch.
>>
>>> >> We have `xdg-runtime-dir' in xdg.el
>>>
>>> Daniel> The goal was to avoid loading `xdg.el' unnecessarily for this trivial
>>> Daniel> function, which is just a wrapper around `getenv'. Do you suggest to use
>>> Daniel> `declare-function' and require xdg inside `browse-url-qutebrowser-send'?
>>>
>>> That would work.
>>
>> I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead
>> of replacing it by this:
>>
>> (declare-function xdg-runtime-dir "xdg")
>> (require 'xdg)
>
> These are only required because you load a new dependency.
> Further these functions can take care of later eventualities if needed,
> e.g. such as handling when a xdg variable isn't set.
> Also using these functions makes the code easier to read as you can
> follow the code down further to the documentation.
The entire function looks like this:
(defun xdg-runtime-dir ()
(getenv "XDG_RUNTIME_DIR"))
No eventualities are handled there right now, so it does not seem
justified to load xdg.el only for this small wrapper. Note that
`browse-url' contains other platform-specific code, including
xdg-related code, without loading xdg.el - all the code around
`browse-url-xdg-open'.
See also the files files.el, server.el, startup.el and mpc.el, which all
access XDG_* environment variables via `getenv' without requiring
xdg.el. The `getenv' function calls are certainly not less readable than
`xdg-runtime-dir'.
That being said, I would not mind if there was a (require 'xdg) at the
top of the browse-url.el file, if that's considered acceptable, even on
systems which do not conform to xdg. For example xdg.el is also required
unconditionally by eww.el and xdg is a fairly small library. Then using
`xdg-runtime-dir' would be the better solution of course.
Daniel
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 7:04 bug#74781: [PATCH] Add `browse-url-qutebrowser' Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 8:27 ` Robert Pluim
@ 2024-12-11 14:40 ` Eli Zaretskii
2024-12-11 15:12 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-14 12:50 ` bug#74781: Status: " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2024-12-11 14:40 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74781
> Date: Wed, 11 Dec 2024 08:04:29 +0100
> From: Daniel Mendler via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> The browser launcher supports the NEW-WINDOW argument and
> `browse-url-qutebrowser-new-window-is-tab' to open tabs. Furthermore
> opening new URLs is speed up via Unix socket IPC if available.
Thanks.
> Furthermore opening new URLs is speed up via Unix socket IPC if
> available. ^^^^^^^^
Typo: "sped up"
> (browse-url-qutebrowser-program, browse-url-qutebrowser-arguments,
> browse-url-qutebrowser-new-window-is-tab): New customizables.
Our conventions are to format these kinds of identifier lists
differently:
(browse-url-qutebrowser-program, browse-url-qutebrowser-arguments)
(browse-url-qutebrowser-new-window-is-tab): New customizables.
IOW, the list should be closed at EOL, and then reopened on the next
line. This makes searching for changes of a function/variable easier.
> +(defcustom browse-url-qutebrowser-program "qutebrowser"
> + "The name by which to invoke Qutebrowser."
> + :type 'string)
Please add a :version tag.
> +(defcustom browse-url-qutebrowser-arguments nil
> + "A list of strings to pass to Qutebrowser when it starts up."
> + :type '(repeat (string :tag "Argument")))
Same here.
> +(defcustom browse-url-qutebrowser-new-window-is-tab nil
> + "Whether to open up new windows in a tab or a new window.
The first line of this doc string should mention Qutebrowser, so that
the various apropos commands could find this variable when the user
wants to look up something Qutebrowser-related.
> +If non-nil, then open the URL in a new tab rather than a new window if
> +`browse-url-qutebrowser' is asked to open it in a new window."
The "is asked to open it in a new window" part confused me: asked by
whom? Is this something that Emacs does, or something else?
> + :type 'boolean)
The :version tag is missing.
> +(defun browse-url-qutebrowser-send (cmd)
> + "Send CMD to Qutebrowser via IPC."
> + (let* ((dir (getenv "XDG_RUNTIME_DIR"))
^^^^^^^^^^^^^^^^^^^^^^^^^^
Why not use xdg-runtime-dir instead?
> + (sock (and dir (expand-file-name
> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
> + dir))))
I think Qutebrowser is available on Windows, where we don't (yet)
support local sockets. So I think there should be some kind of test
for running on Windows, and falling back to alternatives.
Last, but not least: I think the fact that Emacs will now support
Qutebrowser warrants a NEWS entry.
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 14:40 ` Eli Zaretskii
@ 2024-12-11 15:12 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 15:44 ` Robert Pluim
2024-12-11 16:54 ` Eli Zaretskii
0 siblings, 2 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 15:12 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74781
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
Hello Eli,
thanks. I added the version tags, the NEWS entry, improved the
docstrings and use `xdg-runtime-dir' now. See the updated patch
attached to this mail.
>> + (sock (and dir (expand-file-name
>> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
>> + dir))))
>
> I think Qutebrowser is available on Windows, where we don't (yet)
> support local sockets. So I think there should be some kind of test
> for running on Windows, and falling back to alternatives.
On Windows, the socket won't be there, and the new Qutebrowser window
will be opened by the newly executed Qutebrowser process via
`call-process'. This will work but is unfortunately slower.
Daniel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-browse-url-qutebrowser.patch --]
[-- Type: text/x-diff, Size: 7405 bytes --]
From c5286d132bb1afa6078b45e0f7df9ecdecf104ce Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
Date: Wed, 11 Dec 2024 07:36:16 +0100
Subject: [PATCH] Add `browse-url-qutebrowser'
The browser launcher supports the NEW-WINDOW argument and
`browse-url-qutebrowser-new-window-is-tab' to open tabs.
Furthermore opening new URLs is sped up via Unix socket IPC if
available.
* lisp/net/browse-url.el (browse-url-qutebrowser-send): Function
to send command to Qutebrowser via IPC.
(browse-url-qutebrowser): New browser launcher. Use
`browse-url-qutebrowser-send'.
(browse-url-qutebrowser-program, browse-url-qutebrowser-arguments)
(browse-url-qutebrowser-new-window-is-tab): New customizables.
(browse-url-mozilla-new-window-is-tab)
(browse-url-firefox-new-window-is-tab)
(browse-url-epiphany-new-window-is-tab): Improve docstrings.
* etc/NEWS: Announce the change.
---
etc/NEWS | 6 +++
lisp/net/browse-url.el | 93 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 91 insertions(+), 8 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 043e55edf3e..add18c68d4e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -296,6 +296,12 @@ modal editing packages.
\f
* Changes in Specialized Modes and Packages in Emacs 31.1
+** Browse URL
+
+*** New function 'browse-url-qutebrowser' for the Qutebrowser.
+For better integration with the Qutebrowser, set
+'browse-url(-secondary)-browser-function' to 'browse-url-qutebrowser'.
+
** CL-Lib
+++
*** 'cl-labels' now also accepts (FUNC EXP) bindings, like 'cl-flet'.
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 8ec025d017b..e96a24d3ff1 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -140,6 +140,7 @@
;;; Code:
(require 'url)
+(require 'xdg)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variables
@@ -342,6 +343,16 @@ browse-url-epiphany-startup-arguments
`browse-url' is loaded."
:type '(repeat (string :tag "Argument")))
+(defcustom browse-url-qutebrowser-program "qutebrowser"
+ "The name by which to invoke Qutebrowser."
+ :type 'string
+ :version "31.1")
+
+(defcustom browse-url-qutebrowser-arguments nil
+ "A list of strings to pass to Qutebrowser when it starts up."
+ :type '(repeat (string :tag "Argument"))
+ :version "31.1")
+
(defcustom browse-url-webpositive-program "WebPositive"
"The name by which to invoke WebPositive."
:type 'string
@@ -360,33 +371,45 @@ browse-url-gnome-moz-arguments
(make-obsolete-variable 'browse-url-gnome-moz-arguments nil "25.1")
(defcustom browse-url-mozilla-new-window-is-tab nil
- "Whether to open up new windows in a tab or a new window.
+ "Whether to open up new Mozilla windows in a tab or a new window.
If non-nil, then open the URL in a new tab rather than a new window if
-`browse-url-mozilla' is asked to open it in a new window."
+`browse-url-mozilla' is asked to open it in a new window via the
+NEW-WINDOW argument."
:type 'boolean)
(make-obsolete-variable 'browse-url-mozilla-new-window-is-tab nil "29.1")
(defcustom browse-url-firefox-new-window-is-tab nil
- "Whether to open up new windows in a tab or a new window.
+ "Whether to open up new Firefox windows in a tab or a new window.
If non-nil, then open the URL in a new tab rather than a new window if
-`browse-url-firefox' is asked to open it in a new window."
+`browse-url-firefox' is asked to open it in a new window via the
+NEW-WINDOW argument."
:type 'boolean)
(defcustom browse-url-conkeror-new-window-is-buffer nil
- "Whether to open up new windows in a buffer or a new window.
+ "Whether to open up new Conkeror windows in a buffer or a new window.
If non-nil, then open the URL in a new buffer rather than a new window if
-`browse-url-conkeror' is asked to open it in a new window."
+`browse-url-conkeror' is asked to open it in a new window via the
+NEW-WINDOW argument."
:version "25.1"
:type 'boolean)
(make-obsolete-variable 'browse-url-conkeror-new-window-is-buffer nil "28.1")
(defcustom browse-url-epiphany-new-window-is-tab nil
- "Whether to open up new windows in a tab or a new window.
+ "Whether to open up new Epiphany windows in a tab or a new window.
If non-nil, then open the URL in a new tab rather than a new window if
-`browse-url-epiphany' is asked to open it in a new window."
+`browse-url-epiphany' is asked to open it in a new window via the
+NEW-WINDOW argument."
:type 'boolean)
+(defcustom browse-url-qutebrowser-new-window-is-tab nil
+ "Whether to open up new Qutebrowser windows in a tab or a new window.
+If non-nil, then open the URL in a new tab rather than a new window if
+`browse-url-qutebrowser' is asked to open it in a new window via the
+NEW-WINDOW argument."
+ :type 'boolean
+ :version "31.1")
+
(defcustom browse-url-new-window-flag nil
"Non-nil means always open a new browser window with appropriate browsers.
Passing an interactive argument to \\[browse-url], or specific browser
@@ -1294,6 +1317,60 @@ browse-url-epiphany-sentinel
browse-url-epiphany-program
(append browse-url-epiphany-startup-arguments (list url))))))
+(defun browse-url-qutebrowser-send (cmd)
+ "Send CMD to Qutebrowser via IPC."
+ (let* ((dir (xdg-runtime-dir))
+ (sock (and dir (expand-file-name
+ (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
+ dir))))
+ (unless (file-exists-p sock)
+ (error "No Qutebrowser IPC socket found"))
+ (let ((proc
+ (make-network-process
+ :name "qutebrowser"
+ :family 'local
+ :service sock
+ :coding 'utf-8)))
+ (unwind-protect
+ (process-send-string
+ proc
+ (concat
+ (json-serialize `( :args [,cmd]
+ :target_arg :null
+ :protocol_version 1))
+ "\n"))
+ (delete-process proc)))))
+
+(defun browse-url-qutebrowser (url &optional new-window)
+ "Ask the Qutebrowser WWW browser to load URL.
+Default to the URL around or before point.
+
+When called interactively, if variable `browse-url-new-window-flag' is
+non-nil, load the document in a new Qutebrowser window, otherwise use a
+random existing one. A non-nil interactive prefix argument reverses
+the effect of `browse-url-new-window-flag'.
+
+If `browse-url-qutebrowser-new-window-is-tab' is non-nil, then whenever a
+document would otherwise be loaded in a new window, it is loaded in a
+new tab in an existing window instead.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of `browse-url-new-window-flag'."
+ (interactive (browse-url-interactive-arg "URL: "))
+ (let ((cmd (concat ":open "
+ (and (browse-url-maybe-new-window new-window)
+ (if browse-url-qutebrowser-new-window-is-tab
+ "-t " "-w "))
+ (browse-url-encode-url url))))
+ (condition-case nil
+ (browse-url-qutebrowser-send cmd)
+ (error
+ (apply #'start-process (concat "qutebrowser " url) nil
+ browse-url-qutebrowser-program
+ (append browse-url-qutebrowser-arguments (list cmd)))))))
+
+(function-put 'browse-url-qutebrowser 'browse-url-browser-kind 'external)
+
(defvar url-handler-regexp)
;;;###autoload
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 10:45 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 15:32 ` Eli Zaretskii
2024-12-11 15:36 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2024-12-11 15:32 UTC (permalink / raw)
To: Daniel Mendler; +Cc: rpluim, 74781
> Cc: 74781@debbugs.gnu.org
> Date: Wed, 11 Dec 2024 11:45:38 +0100
> From: Daniel Mendler via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead of
> replacing it by this:
>
> (declare-function xdg-runtime-dir "xdg")
> (require 'xdg)
> (xdg-runtime-dir)
What if some day we decide that XDG_RUNTIME_DIR can fall back on, say,
~/.config/runtime/ ?
xdg.el exists to let us avoid leaking abstractions, so I think we
should use it even if the function is a trivial wrapper around getenv.
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 15:32 ` Eli Zaretskii
@ 2024-12-11 15:36 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 15:36 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: rpluim, 74781
Eli Zaretskii <eliz@gnu.org> writes:
>> Cc: 74781@debbugs.gnu.org
>> Date: Wed, 11 Dec 2024 11:45:38 +0100
>> From: Daniel Mendler via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> I would be pragmatic and keep the (getenv "XDG_RUNTIME_DIR"), instead of
>> replacing it by this:
>>
>> (declare-function xdg-runtime-dir "xdg")
>> (require 'xdg)
>> (xdg-runtime-dir)
>
> What if some day we decide that XDG_RUNTIME_DIR can fall back on, say,
> ~/.config/runtime/ ?
>
> xdg.el exists to let us avoid leaking abstractions, so I think we
> should use it even if the function is a trivial wrapper around getenv.
Sure, this could happen in the future. I've changed this in the latest
patch which I've sent.
Daniel
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 15:12 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 15:44 ` Robert Pluim
2024-12-11 15:54 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 16:54 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: Robert Pluim @ 2024-12-11 15:44 UTC (permalink / raw)
To: Daniel Mendler; +Cc: Eli Zaretskii, 74781
>>>>> On Wed, 11 Dec 2024 16:12:23 +0100, Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:
Daniel> Hello Eli,
Daniel> thanks. I added the version tags, the NEWS entry, improved the
Daniel> docstrings and use `xdg-runtime-dir' now. See the updated patch
Daniel> attached to this mail.
>>> + (sock (and dir (expand-file-name
>>> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
>>> + dir))))
>>
>> I think Qutebrowser is available on Windows, where we don't (yet)
>> support local sockets. So I think there should be some kind of test
>> for running on Windows, and falling back to alternatives.
Daniel> On Windows, the socket won't be there, and the new Qutebrowser window
Daniel> will be opened by the newly executed Qutebrowser process via
Daniel> `call-process'. This will work but is unfortunately slower.
And it will check for the socket for every URL. Could you perhaps test
whether to use the socket or not just once, and then use the
appropriate call?
Robert
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 15:44 ` Robert Pluim
@ 2024-12-11 15:54 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-11 15:54 UTC (permalink / raw)
To: Robert Pluim; +Cc: Eli Zaretskii, 74781
Robert Pluim <rpluim@gmail.com> writes:
>>>>>> On Wed, 11 Dec 2024 16:12:23 +0100, Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> said:
>
> Daniel> Hello Eli,
> Daniel> thanks. I added the version tags, the NEWS entry, improved the
> Daniel> docstrings and use `xdg-runtime-dir' now. See the updated patch
> Daniel> attached to this mail.
>
> >>> + (sock (and dir (expand-file-name
> >>> + (format "qutebrowser/ipc-%s" (md5 (user-login-name)))
> >>> + dir))))
> >>
> >> I think Qutebrowser is available on Windows, where we don't (yet)
> >> support local sockets. So I think there should be some kind of test
> >> for running on Windows, and falling back to alternatives.
>
> Daniel> On Windows, the socket won't be there, and the new Qutebrowser window
> Daniel> will be opened by the newly executed Qutebrowser process via
> Daniel> `call-process'. This will work but is unfortunately slower.
>
> And it will check for the socket for every URL. Could you perhaps test
> whether to use the socket or not just once, and then use the
> appropriate call?
There is only the cheap `file-exists-p' check. It should be fast, in
comparison to what comes after that - the socket creation or the process
creation.
Daniel
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 14:38 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-11 16:16 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2024-12-11 16:16 UTC (permalink / raw)
To: Daniel Mendler; +Cc: bjorn.bidar, 74781, rpluim
> Cc: 74781@debbugs.gnu.org, rpluim@gmail.com
> Date: Wed, 11 Dec 2024 15:38:13 +0100
> From: Daniel Mendler via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> See also the files files.el, server.el, startup.el and mpc.el, which all
> access XDG_* environment variables via `getenv' without requiring
> xdg.el. The `getenv' function calls are certainly not less readable than
> `xdg-runtime-dir'.
We avoid xdg.el in preloaded files, but not elsewhere.
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 15:12 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 15:44 ` Robert Pluim
@ 2024-12-11 16:54 ` Eli Zaretskii
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2024-12-11 16:54 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74781
> From: Daniel Mendler <mail@daniel-mendler.de>
> Cc: 74781@debbugs.gnu.org
> Date: Wed, 11 Dec 2024 16:12:23 +0100
>
> thanks. I added the version tags, the NEWS entry, improved the
> docstrings and use `xdg-runtime-dir' now. See the updated patch
> attached to this mail.
Thanks, this LGTM. Let's wait for a couple of days to let others
chime in if they want.
^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#74781: Status: [PATCH] Add `browse-url-qutebrowser'
2024-12-11 7:04 bug#74781: [PATCH] Add `browse-url-qutebrowser' Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 8:27 ` Robert Pluim
2024-12-11 14:40 ` Eli Zaretskii
@ 2024-12-14 12:50 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2 siblings, 0 replies; 16+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-14 12:50 UTC (permalink / raw)
To: 74781-done
The patch has been installed on master.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-12-14 12:50 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-11 7:04 bug#74781: [PATCH] Add `browse-url-qutebrowser' Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 8:27 ` Robert Pluim
2024-12-11 9:07 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 9:58 ` Robert Pluim
2024-12-11 10:45 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:14 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:38 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 16:16 ` Eli Zaretskii
2024-12-11 15:32 ` Eli Zaretskii
2024-12-11 15:36 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 14:40 ` Eli Zaretskii
2024-12-11 15:12 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 15:44 ` Robert Pluim
2024-12-11 15:54 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-11 16:54 ` Eli Zaretskii
2024-12-14 12:50 ` bug#74781: Status: " Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.