GNU bug report logs - #74781
[PATCH] Add `browse-url-qutebrowser'

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Wed, 11 Dec 2024 07:05:01 UTC

Severity: normal

Tags: patch

Done: Daniel Mendler <mail <at> daniel-mendler.de>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 74781 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 74781 <at> debbugs.gnu.org
Subject: Re: bug#74781: [PATCH] Add `browse-url-qutebrowser'
Date: Wed, 11 Dec 2024 10:07:08 +0100
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




This bug report was last modified 209 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.