From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#69098: [PATCH] Add new command 'browse-url-here' Date: Sun, 18 Feb 2024 12:36:00 +0000 Message-ID: <87ttm6t0en.fsf@posteo.net> References: <87ttmc7k0h.fsf@posteo.net> <877cj8d1a2.fsf@betli.tmit.bme.hu> <875xyrged4.fsf@posteo.net> <87a5nynp04.fsf@betli.tmit.bme.hu> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30498"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69098@debbugs.gnu.org To: Felician Nemeth Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 18 13:37:03 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 1rbgPm-0007if-SJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Feb 2024 13:37:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbgPU-0000Qa-Kd; Sun, 18 Feb 2024 07:36:44 -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 1rbgPS-0000QM-HV for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 07:36:42 -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 1rbgPS-00078p-8j for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 07:36:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbgPm-0005ac-Gz for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 07:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Feb 2024 12:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69098 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69098-submit@debbugs.gnu.org id=B69098.170825979321452 (code B ref 69098); Sun, 18 Feb 2024 12:37:02 +0000 Original-Received: (at 69098) by debbugs.gnu.org; 18 Feb 2024 12:36:33 +0000 Original-Received: from localhost ([127.0.0.1]:34242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbgPI-0005Zv-UD for submit@debbugs.gnu.org; Sun, 18 Feb 2024 07:36:33 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:57793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbgPE-0005Zf-CV for 69098@debbugs.gnu.org; Sun, 18 Feb 2024 07:36:31 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 91007240028 for <69098@debbugs.gnu.org>; Sun, 18 Feb 2024 13:36:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1708259761; bh=Exvjs5lKR71B1a9LJQJFcLKyTSC80ttPFHhJWMglc68=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version: Content-Type:From; b=gH4FJ788/2iUONldEj30TKXrHNLpWQWuWDQwYGI7qRiwTO+XkSYO1wt/92jjBXiDy bfOqwuGz8BM8XgWZF38sRG3ihxVv3OwQmM8YQgThdbJ1tX6t+b6TX6olA1wEgnNkRE S+WdD9PEkUxr/ZGs5FZeqPMsgUoB/P/4JNM8bmvvvJ6+3JK0sNd2+6LQtYDUItsZp1 dTmwEORF6EbQ93iKy4//XlV2epoc09Gyw8lNeuw4WM6sn++hqO9gZKRfNSg7tM4MTA RN/0EXGfFeOxIDu4noioRVH5sAUaQ+AuPRUKiRJbJbOsKbGZruU3tiQCzoFxtVFxQL m3PXY/AVVpb+A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Td4sF1L1Pz9rxM; Sun, 18 Feb 2024 13:36:01 +0100 (CET) In-Reply-To: <87a5nynp04.fsf@betli.tmit.bme.hu> (Felician Nemeth's message of "Sun, 18 Feb 2024 09:41:15 +0100") X-Hashcash: 1:20:240218:felician.nemeth@gmail.com::/ZJOwd+yv8JKZO5V:0C+T X-Hashcash: 1:20:240218:69098@debbugs.gnu.org::iMv5asD1Qv/9CE28:1yLH Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM 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:280165 Archived-At: Felician Nemeth writes: >>> Philip Kaludercic writes: >>> >>>> The idea is to have a command that can be used to open a file or >>>> directory using something outside Emacs. >>>> >>>> I find this useful, but it might be that there are edge-cases that I am >>>> not considering that don't pop up on my system. > > Now I think the attached patch is more inline with the philosophy of > browse-url than the previous patches of this thread. > > However, this patch might not be necessary. You can open a file with > C-x C-j W or in the secondary browser with C-x C-j C-u W. This seems > cumbersome, but C-x C-j (dired-jump) quickly becomes second nature. And > to open the directory of file: C-x C-j C-x C-j C-u W, which once again > seems frightening, but can be entered quickly without thinking. > > From a5227603c87ae899a6ccf7e581b80a0f6b816946 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= > Date: Sun, 18 Feb 2024 09:22:30 +0100 > Subject: [PATCH] Allow browse-url commands to invoke secondary browser > > * lisp/net/browse-url.el (browse-url-of-file) > (browse-url-of-buffer): Use 'browse-url-secondary-browser-function' > if the new argument 'secondary' is non-nil or when invoked with a > prefix arg. > --- > lisp/net/browse-url.el | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el > index 74740af3bd6..4c4c79a80da 100644 > --- a/lisp/net/browse-url.el > +++ b/lisp/net/browse-url.el > @@ -728,13 +728,16 @@ browse-url-maybe-new-window > ;; Browse current buffer > > ;;;###autoload > -(defun browse-url-of-file (&optional file) > +(defun browse-url-of-file (&optional file secondary) > "Use a web browser to display FILE. > Display the current buffer's file if FILE is nil or if called > interactively. Turn the filename into a URL with function > `browse-url-file-url'. Pass the URL to a browser using the > -`browse-url' function then run `browse-url-of-file-hook'." > - (interactive) > +`browse-url' function then run `browse-url-of-file-hook'. > + > +With a prefix argument, or when SECONDARY is non-nil, use > +`browse-url-secondary-browser-function' instead." > + (interactive (list nil current-prefix-arg)) This would lack the convince feature of being able to also quickly open the current directory, which is what I used the prefix argument for. > (or file > (setq file (buffer-file-name)) > (error "Current buffer has no file")) > @@ -748,7 +751,10 @@ browse-url-of-file > (not browse-url-temp-file-name)) > (setq browse-url-temp-file-name (file-local-copy file) > file browse-url-temp-file-name)) > - (browse-url (browse-url-file-url file)) > + (let ((url (browse-url-file-url file))) > + (if secondary > + (funcall browse-url-secondary-browser-function url) > + (browse-url url))) > (run-hooks 'browse-url-of-file-hook)) > > (defun browse-url--file-name-coding-system () > @@ -789,14 +795,17 @@ browse-url-file-url > file) > > ;;;###autoload > -(defun browse-url-of-buffer (&optional buffer) > +(defun browse-url-of-buffer (&optional buffer secondary) > "Use a web browser to display BUFFER. > See `browse-url' for details. > > Display the current buffer if BUFFER is nil. Display only the > currently visible part of BUFFER (from a temporary file) if buffer is > -narrowed." > - (interactive) > +narrowed. > + > +With a prefix argument, or when SECONDARY is non-nil, use > +`browse-url-secondary-browser-function' instead." > + (interactive (list nil current-prefix-arg)) > (save-excursion > (and buffer (set-buffer buffer)) > (let ((file-name > @@ -816,7 +825,7 @@ browse-url-of-buffer > nil ".html")))) > (setq file-name browse-url-temp-file-name) > (write-region (point-min) (point-max) file-name nil 'no-message)) > - (browse-url-of-file file-name)))) > + (browse-url-of-file file-name secondary)))) > > (defun browse-url-delete-temp-file (&optional temp-file-name) > "Delete `browse-url-temp-file-name' from the file system. -- Philip Kaludercic