From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74781: [PATCH] Add `browse-url-qutebrowser' Date: Wed, 11 Dec 2024 10:07:08 +0100 Message-ID: <87jzc61tc3.fsf@daniel-mendler.de> References: <87msh21z0i.fsf@daniel-mendler.de> <87ed2e8vzv.fsf@gmail.com> Reply-To: Daniel Mendler Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36515"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74781@debbugs.gnu.org To: Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 11 10:50:35 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tLJMY-0009HY-RN for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Dec 2024 10:50:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLJM9-0005rF-B5; Wed, 11 Dec 2024 04:50:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLJM2-0005ma-Oj for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 04:50:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLJM2-0004pu-DM for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 04:50:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=3EFa2MIm/jsQAS2fBCGmmxx/N27G4NHSI3U/0+hWqQE=; b=mn0e0cUqrkEwwKp0NugFoZvPYO8QiPKKWCFRBGrbqc+v2zCDHh5lpSM+TzWl+8H9+dNyvM31qrrZfLMI67bZUqXyywKsO3n2/LHXoEzZVypSQVXhtXgoH9IBDGJ5uDQPSE0zXCWc0szi/pGw03cPURVr76s96Hq5jV2S4LMF6+EXgLLhYKzkX5AQ8to+6bPzwlU4jgGSD38Fvm4mCtbW9+OmvSJehdUeCQKtI5vb7vd+FqSevPeL4h9zYbGSUCc41lQ+/TXdOrDsVwqYtjD8teJWjGd0OaPiMxPqau48Amj+bRjOZVDjwu2E/YN1jQSd7L3PzGme8Hh92CRA/zqtCQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLIjK-0007le-CW for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 04:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Dec 2024 09:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74781 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74781-submit@debbugs.gnu.org id=B74781.173390817529802 (code B ref 74781); Wed, 11 Dec 2024 09:10:02 +0000 Original-Received: (at 74781) by debbugs.gnu.org; 11 Dec 2024 09:09:35 +0000 Original-Received: from localhost ([127.0.0.1]:32870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLIis-0007ka-RV for submit@debbugs.gnu.org; Wed, 11 Dec 2024 04:09:35 -0500 Original-Received: from server.qxqx.de ([49.12.34.165]:54637 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLIim-0007k9-Vc for 74781@debbugs.gnu.org; Wed, 11 Dec 2024 04:09:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=daniel-mendler.de; s=key; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3EFa2MIm/jsQAS2fBCGmmxx/N27G4NHSI3U/0+hWqQE=; b=ZEOI1IfDcYa+iiHAstGoIl3HGL SE7em9qE4I0x412faM98hyimFqlZVT0nU9XvE4otLbxWl6dtoJ872D/+T2LBOlqc2+HnDaraQaiu5 c96G/vdkyoXsEajBHuGd6VHWrtKsBiMJ5n3tEfqdHiE3xf9B6blbS9EFyVtK0+iCFdNc=; In-Reply-To: <87ed2e8vzv.fsf@gmail.com> (Robert Pluim's message of "Wed, 11 Dec 2024 09:27:48 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296812 Archived-At: 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 u= p." > 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 appro= priate browsers. > Daniel> Passing an interactive argument to \\[browse-url], or specif= ic 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=CA=BCm 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