From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#74781: [PATCH] Add `browse-url-qutebrowser' Date: Wed, 11 Dec 2024 09:27:48 +0100 Message-ID: <87ed2e8vzv.fsf@gmail.com> References: <87msh21z0i.fsf@daniel-mendler.de> 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="34763"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Daniel Mendler To: 74781@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 11 09:30:20 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 1tLI6u-0008ve-3Q for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Dec 2024 09:30:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLI6g-0001iQ-IH; Wed, 11 Dec 2024 03:30:06 -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 1tLI6d-0001bh-3h for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 03:30: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 1tLI6c-0004gX-Pe for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 03:30: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=tZIOCap6FMH/KmAq//PD9M/D+LXGz3Ezi858xbwA+hk=; b=QYOSaUY5hB3yG336gRvQQUuK4hGRth1QJQH7cFTUoLaFaennldEWZHlqJcm2uOMy57Oj3qIZZ9RjznFntt/ryKxS1cfsVtxWuW/jYEdjxC5lIktVVutU1z60RcpT6eA2SPk8u3Awch10mkFiVx7sm7oRcrP+pvOBNeM4TMnGHwKeXilAeFmDdbzb01IwYKg+143qQOpiCbiDLlq6HqW3K9L2rwEMVVqryCHy3u8nep+f1NJbvtaEm4PpwLhlQ12WY1Pk6s94Rje4PEZ4TJ33mL+1AXtMT2SY1pfeStdji+DGc1XMZYlGdT+ia2tQ7mlDWgDUadiepW5NETL0fExR5w==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLI6b-0005at-TO for bug-gnu-emacs@gnu.org; Wed, 11 Dec 2024 03:30:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Dec 2024 08:30:01 +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.173390574621271 (code B ref 74781); Wed, 11 Dec 2024 08:30:01 +0000 Original-Received: (at 74781) by debbugs.gnu.org; 11 Dec 2024 08:29:06 +0000 Original-Received: from localhost ([127.0.0.1]:32818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLI5d-0005Wg-UJ for submit@debbugs.gnu.org; Wed, 11 Dec 2024 03:29:06 -0500 Original-Received: from mail-wr1-f51.google.com ([209.85.221.51]:50408) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLI5Y-0005WN-Bh for 74781@debbugs.gnu.org; Wed, 11 Dec 2024 03:29:00 -0500 Original-Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-382610c7116so3303348f8f.0 for <74781@debbugs.gnu.org>; Wed, 11 Dec 2024 00:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733905670; x=1734510470; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=tZIOCap6FMH/KmAq//PD9M/D+LXGz3Ezi858xbwA+hk=; b=ZuQ4c02cI6pLm2XViHni44Azx1X8XXaW494LiYnSfNejd1aQak1ku6MAd2VJ6OeIPJ fPS4pNVEyfIYy2DnclnjVQm4tLMklovSsNc+SikB5Imw9gSP4CKCyDCaTpRbQ2/Ro+D+ S18YK0rFXuHksXy6v54owSPrZKVMlAyX7HvmxWnXu//decXv7NfQkeENpe6B+HfCSJ/A W0wy1d5BBER/LVnwctkRqVQXRKxi90zSNoUevd3uY+OYeptwW8ey6UnYpydqtEuT7D75 Nl6DGrCIsUhfOvjQ1+IHBM4uLIVweFF8CVK6EX7np5UTKFGzwGFcH12mFcuwXxvpmN7o 8rwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733905670; x=1734510470; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tZIOCap6FMH/KmAq//PD9M/D+LXGz3Ezi858xbwA+hk=; b=ceDPu2A+WsvKtwstCXxMVB3EqFD5XoIITzJLpdXUdo1GnTp9q7pGvqp//KdHmIxz9g VYysHZMcNVOT7zcGpyL/VTKUlzUbtFM1odVTDVH4QGuKqr1iZ/CMCflzPoMWDA4B0wD3 v1+MwRX2kBQ19blQjrop/LI+IFA0Rq9Ku6+NSMBG3bzDnXGQa/WxDL1kdHRbgDeYKmHV soD7u40emPIsab98Q9Z7JjVqFwbT8+NiBBw+bY/kwJj1cHzzFKef/0SJM2Q5itZx2ckJ 1ZwNcivyoZDt4wB+Ui+TOlRI1CkH4XggS+1NCGwo1e8DwWuqoavR5jXEDP7OPUShH1jy 654g== X-Gm-Message-State: AOJu0Yx8fvdbZnulFzSSl4sK0170wjY0jgR1b3hjeMubXecpp8rIDck6 Cr5zikvrpWi+8MyZGK13kU8WGKBdVQlEQruH0UzY5I6QEutFDUvqnuf1LQ== X-Gm-Gg: ASbGncv6dWglsDMWRTbAnZGC6hxA3DFFENNQI7ZopMAtDHDL60RnKmB8edwv7YIfoBG cR+RIl4xv+czizYM1G9sglLLKnioKpeLfvhdQzDNsMMJcFKbuMahU+PTsmj8X6x2LgdfNjT2uuJ bT51f1w4zcgF9gbJHG64LztiPXQUEPAMHNmHzbR/FRMtd/wxCQXMf4R15xg5oKV2kr9TASeDu+8 5hkM/JatpFUue6LcywyYHZ+oPfSnxd+paA52+qMCQ== X-Google-Smtp-Source: AGHT+IH0clTdStgEGbCbKY3sNF88cabejNjohxlAnPkWZDJjD5UYSbahfgBpGhbhvjSCYbVOauhn0A== X-Received: by 2002:a05:6000:4804:b0:385:e429:e59a with SMTP id ffacd0b85a97d-3864ce5ff30mr1606487f8f.25.1733905670099; Wed, 11 Dec 2024 00:27:50 -0800 (PST) Original-Received: from rltb ([2a01:e0a:3f3:fb51:a443:b1bf:de94:83c1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-435c1833d67sm42456875e9.5.2024.12.11.00.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 00:27:49 -0800 (PST) In-Reply-To: <87msh21z0i.fsf@daniel-mendler.de> (Daniel Mendler via's message of "Wed, 11 Dec 2024 08:04:29 +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:296809 Archived-At: >>>>> On Wed, 11 Dec 2024 08:04:29 +0100, Daniel Mendler via "Bug reports f= or GNU Emacs, the Swiss army knife of text editors" = said: =20 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) =20 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 w= indow 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 appropr= iate 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 ur= l)))))) =20 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 (us= er-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. Robert --=20