GNU bug report logs - #69098
[PATCH] Add new command 'browse-url-here'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Philip Kaludercic <philipk@HIDDEN>; Keywords: patch; dated Tue, 13 Feb 2024 10:11:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 69098 <at> debbugs.gnu.org:


Received: (at 69098) by debbugs.gnu.org; 18 Feb 2024 12:36:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 18 07:36:33 2024
Received: from localhost ([127.0.0.1]:34242 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rbgPI-0005Zv-UD
	for submit <at> debbugs.gnu.org; Sun, 18 Feb 2024 07:36:33 -0500
Received: from mout01.posteo.de ([185.67.36.65]:57793)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1rbgPE-0005Zf-CV
 for 69098 <at> debbugs.gnu.org; Sun, 18 Feb 2024 07:36:31 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 91007240028
 for <69098 <at> 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==
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)
From: Philip Kaludercic <philipk@HIDDEN>
To: Felician Nemeth <felician.nemeth@HIDDEN>
Subject: Re: bug#69098: [PATCH] Add new command 'browse-url-here'
In-Reply-To: <87a5nynp04.fsf@HIDDEN> (Felician Nemeth's message of
 "Sun, 18 Feb 2024 09:41:15 +0100")
References: <87ttmc7k0h.fsf@HIDDEN> <877cj8d1a2.fsf@HIDDEN>
 <875xyrged4.fsf@HIDDEN> <87a5nynp04.fsf@HIDDEN>
X-Hashcash: 1:20:240218:felician.nemeth@HIDDEN::/ZJOwd+yv8JKZO5V:0C+T
X-Hashcash: 1:20:240218:69098 <at> debbugs.gnu.org::iMv5asD1Qv/9CE28:1yLH
Autocrypt: addr=philipk@HIDDEN; keydata=
 mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo
 aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0
 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI
 BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0
 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB
 BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE
 Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK
 NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof
 z4oM
Date: Sun, 18 Feb 2024 12:36:00 +0000
Message-ID: <87ttm6t0en.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 69098
Cc: 69098 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

Felician Nemeth <felician.nemeth@HIDDEN> writes:

>>> Philip Kaludercic <philipk@HIDDEN> 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?= <felician.nemeth@HIDDEN>
> 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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69098; Package emacs. Full text available.

Message received at 69098 <at> debbugs.gnu.org:


Received: (at 69098) by debbugs.gnu.org; 18 Feb 2024 08:42:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Feb 18 03:42:47 2024
Received: from localhost ([127.0.0.1]:34136 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rbcl4-0005Qx-EL
	for submit <at> debbugs.gnu.org; Sun, 18 Feb 2024 03:42:47 -0500
Received: from mail-ej1-f41.google.com ([209.85.218.41]:44436)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felician.nemeth@HIDDEN>) id 1rbcl2-0005QY-6u
 for 69098 <at> debbugs.gnu.org; Sun, 18 Feb 2024 03:42:45 -0500
Received: by mail-ej1-f41.google.com with SMTP id
 a640c23a62f3a-a3e7ce7dac9so12381866b.1
 for <69098 <at> debbugs.gnu.org>; Sun, 18 Feb 2024 00:42:23 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1708245677; x=1708850477; darn=debbugs.gnu.org;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=KI3fhPfEvvZs9IaAeBuR72ijU2Q7E9vLjZ3gIwyDqtc=;
 b=LWyORp5YBOhRv4yFhgf+rsFacVDEpOgnFwTiPMWvcWGH8b8nFyO99ZWOywxls9tbjx
 VgqSdzmjwfm1Py2GupIXIosVof32ceZalEqWHvZN9s/j3QDRSUiFb6ysYkKcnPBNJ9A/
 Z3tcWfTXg6CbuZ4/Qp/i53mgU5ytyYYIug6I4iwJ8UVVQDvTDd68Zk6PFH0jtgvHsP/Z
 VFWw1B5fzpf6rl0NI2uuegF5Ef+JvNvMBn/TkZE8e2ME82QcJTB+4vsEpwWgaTRoKb6m
 bLM6KgJiTVez0AX6FaLs6phYdmSyD3AHdUOZfeh/Z0ykjwl4RX7CrXKV5b+In9A/vVwZ
 LcxQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1708245677; x=1708850477;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=KI3fhPfEvvZs9IaAeBuR72ijU2Q7E9vLjZ3gIwyDqtc=;
 b=hVx18zj+3qsH54Jl/JnSKgemUh9uPPNCbm/zEAG3EFtRKJqcpVDFVIf/pYO/L6LEdP
 u3ouCSZyP6gfxlry1UQSCNzL50d8DT72JPbBtWxP/7hgByg2DW85SY2R40yjRnaJAgfQ
 P4ggMbLXZVwAAmQ/H6WC3JpJcqVtNbxAY8c2uxTFOzivCI0aIwckQ3s3Vy2OHecM9jlp
 X3zN777fsuZIg5vgqaHit4htTlWLQ7yjd2hMZSHeicOnSjRxFeCK3ZtH7/fb4QAw3kjN
 X1Yge/UZCvdLSCSy6wOZ0cSoulKZoGj2/ozk5OawXJ73VvEBk7VEuHNeKQCiKCn1kz+Y
 KN7w==
X-Gm-Message-State: AOJu0YzCgiRYeqYXhGoSau1qdyZbWqfi1ds7Fp5LiMkmZkoJRYOs5dh8
 Hff7f/NhUjY3JFNhOGTuQc1dck3dGAqQ4SyfKMt9z2ldWq6wDEX7OCkttlCo
X-Google-Smtp-Source: AGHT+IHkfhOHAKMhgT3dH5JqThTlMyMOvVoU/Rh/xHw3nMyuSiyJHChu77ogVO4mxVBjouNUF+Ct3w==
X-Received: by 2002:a17:906:d9d1:b0:a3e:4813:d4d8 with SMTP id
 qk17-20020a170906d9d100b00a3e4813d4d8mr1890279ejb.46.1708245677059; 
 Sun, 18 Feb 2024 00:41:17 -0800 (PST)
Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu.
 [213.222.160.137]) by smtp.gmail.com with ESMTPSA id
 cu15-20020a170906ba8f00b00a3e29652a3csm1255491ejd.194.2024.02.18.00.41.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 18 Feb 2024 00:41:16 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Philip Kaludercic <philipk@HIDDEN>
Subject: Re: bug#69098: [PATCH] Add new command 'browse-url-here'
References: <87ttmc7k0h.fsf@HIDDEN> <877cj8d1a2.fsf@HIDDEN>
 <875xyrged4.fsf@HIDDEN>
Date: Sun, 18 Feb 2024 09:41:15 +0100
In-Reply-To: <875xyrged4.fsf@HIDDEN> (Philip Kaludercic's message of "Wed, 
 14 Feb 2024 17:11:35 +0000")
Message-ID: <87a5nynp04.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/
 //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f
 onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd
 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO
 Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh
 LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody
 JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br
 LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4
 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA
 AAAASUVORK5CYII=
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 69098
Cc: 69098 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.9 (--)

--=-=-=
Content-Type: text/plain

>> Philip Kaludercic <philipk@HIDDEN> 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.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Allow-browse-url-commands-to-invoke-secondary-browse.patch

From a5227603c87ae899a6ccf7e581b80a0f6b816946 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@HIDDEN>
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))
   (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.
-- 
2.39.2


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69098; Package emacs. Full text available.

Message received at 69098 <at> debbugs.gnu.org:


Received: (at 69098) by debbugs.gnu.org; 14 Feb 2024 17:12:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Feb 14 12:12:04 2024
Received: from localhost ([127.0.0.1]:52971 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1raInj-0005ux-UM
	for submit <at> debbugs.gnu.org; Wed, 14 Feb 2024 12:12:04 -0500
Received: from mout01.posteo.de ([185.67.36.65]:40401)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1raInh-0005uR-9J
 for 69098 <at> debbugs.gnu.org; Wed, 14 Feb 2024 12:12:02 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id BD203240029
 for <69098 <at> debbugs.gnu.org>; Wed, 14 Feb 2024 18:11:36 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1707930696; bh=BKsC0aQIGCRmhgLhiIan3md8bf3KiXp6DHc4so7sGMw=;
 h=From:To:Cc:Subject:OpenPGP:Date:Message-ID:MIME-Version:
 Content-Type:From;
 b=qbp/+3TGhqsUqL+UlS7FZn1uByXUN4S3AsRmWEtEkxGdpnxBbgNIn72MEnZpVPfS9
 FzZwfxyLobNwN/DfiAdcKO/4o3G3Sy5HTtbM0kSOkxPVdyIaIbOd6LEX13246Lp1lK
 ++LwElwWzTe12gJDJoKbCvYxYcvTP1c1zYA9e8Yzn18VEFHep2UARoBc4ihd7MwsCV
 pTYr7/XvWzqSMDEQyIU6gCA49m597GP3Z8+zZbCX4NLp2WXx4OfHB41OA0P884rROF
 VA730aVFrLwcBhCJxlE0QbQIj1oJDKzSUVmOKYvNPGIDdqMBrLjaG9wKTzaby7qB7l
 m3lZ4IPCj9Lrw==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TZl941RDHz9rxb;
 Wed, 14 Feb 2024 18:11:36 +0100 (CET)
From: Philip Kaludercic <philipk@HIDDEN>
To: Felician Nemeth <felician.nemeth@HIDDEN>
Subject: Re: bug#69098: [PATCH] Add new command 'browse-url-here'
In-Reply-To: <877cj8d1a2.fsf@HIDDEN> (Felician Nemeth's message of
 "Tue, 13 Feb 2024 12:57:57 +0100")
References: <87ttmc7k0h.fsf@HIDDEN> <877cj8d1a2.fsf@HIDDEN>
OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66;
 url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66";
 preference=signencrypt
Date: Wed, 14 Feb 2024 17:11:35 +0000
Message-ID: <875xyrged4.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -4.2 (----)
X-Debbugs-Envelope-To: 69098
Cc: 69098 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.2 (-----)

--=-=-=
Content-Type: text/plain

Felician Nemeth <felician.nemeth@HIDDEN> writes:

> Philip Kaludercic <philipk@HIDDEN> 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.
>
> Shouldn't it do something when the buffer is modified?

A warning is generated by `browse-url-of-file'.

>> +(defun browse-url-here (arg)
>
> Since browse-url-of-buffer does something similar, the name could be
> more descriptive.   Maybe browse-url-of-buffer-external?  

I like that name, used it.

>> +  "Open current file or directory with external tools.
>> +With prefix argument ARG, open the current `default-directory' instead
>> +of the buffer of the current file."
>
> "the file of the current buffer."

Done, thanks.

>> +  (interactive "P")
>> +  (let ((browse-url-default-handlers '()))
>
> This is strange.  There are other ways to use an external browser-kind.
> Maybe you could use browse-url-secondary-browser-function, which is
> "usually an external browser".

The thing is if `browse-url-default-handlers' includes

  (browse-url--non-html-file-url-p . browse-url-emacs)

then this catches all the requests and the file is always opened in
Emacs.  In this patch I try to only filter out these entries that would
open the file in Emacs:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-new-command-browse-url-of-buffer-external.patch

From 58cc4a8a3fc8d5ae87c1a443d02715d65c776675 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@HIDDEN>
Date: Tue, 13 Feb 2024 11:08:09 +0100
Subject: [PATCH] Add new command 'browse-url-of-buffer-external'

* lisp/net/browse-url.el (browse-url-of-buffer-external): Add it.
* etc/NEWS: Document it.
---
 etc/NEWS                           |   4 +
 etc/package-autosuggest.eld        |  11 +++
 lisp/net/browse-url.el             |  20 +++++
 lisp/textmodes/markdown-ts-mode.el | 135 +++++++++++++++++++++++++++++
 4 files changed, 170 insertions(+)
 create mode 100644 etc/package-autosuggest.eld
 create mode 100644 lisp/textmodes/markdown-ts-mode.el

diff --git a/etc/NEWS b/etc/NEWS
index a2b5e0d1a9a..b7c9fc9aa81 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -324,6 +324,10 @@ Previously, it was set to t but this broke remote file name detection.
 ** Multi-character key echo now ends with a suggestion to use Help.
 Customize 'echo-keystrokes-help' to nil to prevent that.
 
+** New command 'browse-url-of-buffer-external'.
+This command opens the current file or directory using an external tool,
+as defined by 'browse-url-secondary-browser-function'.
+
 
 * Editing Changes in Emacs 30.1
 
diff --git a/etc/package-autosuggest.eld b/etc/package-autosuggest.eld
new file mode 100644
index 00000000000..87c7e382026
--- /dev/null
+++ b/etc/package-autosuggest.eld
@@ -0,0 +1,11 @@
+((sml-mode auto-mode-alist "\\.sml\\'")
+ (lua-mode auto-mode-alist "\\.lua\\'" )
+ (ada-mode auto-mode-alist "\\.ada\\'")
+ ;; ...
+ ;;
+ ;; this is just for testing, in practice I think this data should
+ ;; be generated and bundled with Emacs, and would ideally be
+ ;; loaded in at compile-time.  When the "archive-contents" file
+ ;; format is updated, we can include more information in there
+ ;; that would be added to this database.
+ )
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index bc2a7db9a8b..e017d679d84 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -943,6 +943,26 @@ browse-url-at-point
 			  browse-url-new-window-flag))
       (error "No URL found"))))
 
+(defun browse-url-of-buffer-external (arg)
+  "Open current file or directory with external tools.
+With prefix argument ARG, open the current `default-directory' instead
+of the file of the current buffer."
+  (interactive "P")
+  (let ((browse-url-browser-function
+         browse-url-secondary-browser-function)
+        (browse-url-default-handlers
+         (seq-filter
+          (lambda (ent) (eq (cdr ent) 'browse-url-emacs))
+          browse-url-default-handlers)))
+    (browse-url-of-file
+     (expand-file-name
+      (cond
+       (arg ".")
+       ((derived-mode-p 'dired-mode)
+        (dired-get-filename))
+       (buffer-file-name)
+       ((user-error "No associated file found")))))))
+
 ;;;###autoload
 (defun browse-url-with-browser-kind (kind url &optional arg)
   "Browse URL with a browser of the given browser KIND.
diff --git a/lisp/textmodes/markdown-ts-mode.el b/lisp/textmodes/markdown-ts-mode.el
new file mode 100644
index 00000000000..60321d789eb
--- /dev/null
+++ b/lisp/textmodes/markdown-ts-mode.el
@@ -0,0 +1,135 @@
+;;; markdown-ts-mode.el --- Markdown editing mode -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023 Free Software Foundation, Inc.
+
+;; Author: Philip Kaludercic <philipk@HIDDEN>
+;; Keywords: languages
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Major mode for Markdown.  The syntax highlighting has been
+;; implemented using Tree Sitter.
+
+;;; Code:
+
+(eval-when-compile (require 'pcase))
+(require 'treesit)
+
+(defgroup markdown-ts-mode '()
+  "Markdown support."
+  :prefix "markdown-ts-"
+  :group 'text)
+
+(defcustom markdown-ts-mode-executable
+  (seq-find #'executable-find '("cmark" "pandoc" "markdown"))
+  "Name of the executable used to render Markdown.
+It should read the Markdown text via stdin, and render HTML via
+the standard output."
+  :type 'string)
+
+(defconst markdown-ts-mode-font-lock-rules
+  (treesit-font-lock-rules
+   :language 'markdown
+   :feature 'bracket
+   '((["[" "]" "{" "}"]) @font-lock-bracket-face)
+   ;; TODO
+   )
+  "Markdown settings suitable for `treesit-font-lock-settings'.")
+
+(defun markdown-ts-mode-insert-markup (left right)
+  "Generate a new command for inserting markup.
+Insert LEFT and RIGHT into the current buffer.
+Both arguments are strings that are inserted LEFT and RIGHT of
+the active region, or if not present the current point.  This
+function is meant to be invoked by other commands that specialise
+on a specific kind of formatting."
+  (lambda ()
+    (interactive)
+    (if (use-region-p)
+        (save-mark-and-excursion
+          (goto-char (region-end))
+          (insert right)
+          (goto-char (region-beginning))
+          (insert left))
+      (insert left)
+      (save-excursion (insert right)))))
+
+(defalias 'markdown-ts-mode-insert-bold
+  (markdown-ts-mode-insert-markup "**" "**")
+  "Insert bold markup.")
+
+(defalias 'markdown-ts-mode-insert-italics
+  (markdown-ts-mode-insert-markup "_" "_")
+  "Insert italic markup.")
+
+;; (defalias 'markdown-ts-mode-insert-link (uri)
+;;   (markdown-ts-mode-insert-markup
+;;    "[" (format "](%s)" uri))
+;;   "Insert a link to a URI."
+;;   (interactive "MURI: ")
+;;   )
+
+(defun markdown-ts-mode-render ()
+  "Render the current buffer using EWW."
+  (interactive)
+  (unless markdown-ts-mode-executable
+    (user-error "No markdown available"))
+  (let ((bounds (bounds-of-thing-at-point (if (use-region-p)
+                                              'region
+                                            'buffer)))
+        (file (make-temp-file "markdown" nil ".html")))
+    (call-process-region (car bounds) (cdr bounds)
+                         markdown-ts-mode-executable
+                         nil (list :file file))
+    (eww-open-file file)))
+
+(defvar-keymap markdown-ts-mode-map
+  "C-c C-f C-b" #'markdown-ts-mode-insert-bold
+  "C-c C-f C-i" #'markdown-ts-mode-insert-italics
+  ;; "C-c C-l" #'markdown-ts-mode-insert-link
+  "C-c C-c" #'markdown-ts-mode-render)
+
+;;;###autoload
+(define-derived-mode markdown-ts-mode text-mode "MD"
+  "Major mode for editing Markdown files.
+This implementation makes use of Tree Sitter (see the Info
+Node `(elisp) Tree-sitter Major Modes'), and relies on external
+support for rendering.  Using `treesit-install-language-grammar'
+you can install a grammar."
+  (unless (treesit-ready-p 'markdown)
+    (user-error "Tree Sitter support is not available"))
+  (treesit-parser-create 'markdown)
+  (setq-local treesit-font-lock-settings
+              markdown-ts-mode-font-lock-rules
+              treesit-font-lock-feature-list
+              '((constant escape-sequence number property)
+                (bracket delimiter error misc-punctuation)
+                (string type)
+                (comment))
+              comment-start "# ")
+  (treesit-major-mode-setup))
+
+(when (treesit-ready-p 'markdown)
+  (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-ts-mode)))
+
+(add-to-list
+ 'treesit-language-source-alist
+ '(markdown "https://github.com/ikatyang/tree-sitter-markdown" "v0.7.1"))
+
+;;; markdown-ts-mode.el ends here
+(provide 'markdown-ts-mode)
-- 
2.43.0


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69098; Package emacs. Full text available.

Message received at 69098 <at> debbugs.gnu.org:


Received: (at 69098) by debbugs.gnu.org; 13 Feb 2024 11:59:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 13 06:59:25 2024
Received: from localhost ([127.0.0.1]:42405 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rZrRd-0000O5-4T
	for submit <at> debbugs.gnu.org; Tue, 13 Feb 2024 06:59:25 -0500
Received: from mail-ed1-f48.google.com ([209.85.208.48]:58575)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <felician.nemeth@HIDDEN>) id 1rZrRa-0000NY-Fw
 for 69098 <at> debbugs.gnu.org; Tue, 13 Feb 2024 06:59:23 -0500
Received: by mail-ed1-f48.google.com with SMTP id
 4fb4d7f45d1cf-55a90a0a1a1so5929178a12.0
 for <69098 <at> debbugs.gnu.org>; Tue, 13 Feb 2024 03:59:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1707825478; x=1708430278; darn=debbugs.gnu.org;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
 bh=eq17LIdPv8/mZFB7BfxvuQxQmWYadJu13KGBW6bmwV0=;
 b=JGqwMApCRErD4NXa7phdhPWO7JLmXK0/qUNG4rQeqhxz/mCcFEyQ7bAP/aLSJ9rxyp
 TeeD9jf2Wr/k4DLmXdCkcxDM7kA3NYWsjwjs+wHMq/R+L5Gp6v0GloDobYXQrs8hN+rz
 kSKiQIOU9BTTe6Zodc1LAa3ZrctzZHOMe9DoqDf/JeltaFU3pZ8VUTjc0cSzsJKz6Twn
 ixyeqeuu5bqLVlpAhVXcC+ZhNjL0DGVnwEqfwZd0C4xPYBiAgCi2mCBajYHgVzIbdfeJ
 3gTIfil/YL5/+vzYDg15MG2O2bLUPqbSRz95CedM2EcEXwAU7ZJfW8es0qwj0IzCNZMz
 IgUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1707825478; x=1708430278;
 h=mime-version:face:user-agent:message-id:in-reply-to:date:references
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=eq17LIdPv8/mZFB7BfxvuQxQmWYadJu13KGBW6bmwV0=;
 b=YuubfL7UFVgZkmCzWJxcfsGDgLM5P6NsOK2b6eaH/rakM2qcMskxOk8rji7HTT2wPf
 G9ODzIP98cn4TUnBtuig5h3E17qzkm2i7VyL/ucCJd2XAqb9WxX2DcIdIKNdkqgcovEz
 6Cig0EBbT36XckZgagl4GPAxiIwmOJSuucihv4X/YU/c4D8I3x2JSVPprNf/a29C3tZZ
 IJykB6kYAKtZguR1S0tcAmHKnE9nwCgSwjFa/98zHqx2+TNmXal/NkXPR9IkTdm/iTjg
 e0bt7uP0h8Ftg3qrHdNJGIODGEkWUXjDQwCDNISWTOOwePoFI03oto96gtAS/KFnxHWf
 eWHg==
X-Gm-Message-State: AOJu0YyGeTFiXIYKaS/0bUmibD4e7HJ6tn3YeUH/XlLUEkTOvcT9TxDL
 lyHtQMIisDVHuf24hV0eL9s/Y3ouZPJIUI+oDcQXanv0jHZSgYioiPbyBPdM
X-Google-Smtp-Source: AGHT+IEubaGZJ7pmb9JQkpQS3CLFGZkofTrvgd1Xg155emL2nZR8SlZf7OLhjA7Yzl5tGEiKm3gPRQ==
X-Received: by 2002:aa7:d6d7:0:b0:55f:4464:d044 with SMTP id
 x23-20020aa7d6d7000000b0055f4464d044mr7740778edr.6.1707825478458; 
 Tue, 13 Feb 2024 03:57:58 -0800 (PST)
Received: from betli.gmail.com (catv-213-222-160-137.catv.fixed.vodafone.hu.
 [213.222.160.137]) by smtp.gmail.com with ESMTPSA id
 fd9-20020a056402388900b005607f899175sm3694005edb.70.2024.02.13.03.57.57
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 13 Feb 2024 03:57:58 -0800 (PST)
From: Felician Nemeth <felician.nemeth@HIDDEN>
To: Philip Kaludercic <philipk@HIDDEN>
Subject: Re: bug#69098: [PATCH] Add new command 'browse-url-here'
References: <87ttmc7k0h.fsf@HIDDEN>
Date: Tue, 13 Feb 2024 12:57:57 +0100
In-Reply-To: <87ttmc7k0h.fsf@HIDDEN> (Philip Kaludercic's message of "Tue, 
 13 Feb 2024 10:09:50 +0000")
Message-ID: <877cj8d1a2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX5+fmhoaEwMDD/
 ///TMNVWAAAAAWJLR0QDEQxM8gAAAAlwSFlzAAAPEgAADxIBIZvyMwAAAAd0SU1FB+AICBUfHgLs
 gGoAAAGXSURBVCjPRdK/b5tAFAfw753gBEwM2ApMbuVIqf+Ko0qiyhOu4sj2xJBYMn/FUdX7UUUZ
 OjHgyvf+yj6IcW6Bjx53934ADEvs8bmEr8UVoTYTOyJO9KoYsVofN8kILdbeJ8Li6YpZWop4xOK0
 VdfIoXmkHn5/5D7/Ts/8THacSqnkKTcMTxgUkVzFnEIRTKwwYYSCvzfg16f0i8YApW/XG/Pm8R49
 dXjxKmRnxv3OwooQWcv4RUYem1fsNe/WU63uk7AmYxk78y32/ee2tZB4fO+WcZ7lnIGEolXW1EGw
 LfkSuQ0XTgRefgNlfNwRNV6QhBxJ8JNxTMUPyBqTd0bjaAP5G7NJRU39z80hLOZTjqB7K3tEEFSj
 aEsuQew6qBxxyhHjVUR7H7NpC9iHJZGLMCEuweqAqE1BHbfK2oRIz9EHYA/+wiFWru9smeVfuWNZ
 2+NFtX80UA1TvJNdytM4DwO4kY7bJz8Qcd0G0ceslZGkkeoBsjUHwF1+jjM3XHaXEZ7mGLfwPFO+
 RV9QLY2iEdmDo78D/gNPaXVYqd+pyQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0wOC0wOFQyMzoz
 MDoyOCswMjowMGy/yHYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTYtMDgtMDhUMjM6MzA6MjgrMDI6
 MDAd4nDKAAAAAElFTkSuQmCC
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69098
Cc: 69098 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Philip Kaludercic <philipk@HIDDEN> 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.

Shouldn't it do something when the buffer is modified?

> +(defun browse-url-here (arg)

Since browse-url-of-buffer does something similar, the name could be
more descriptive.   Maybe browse-url-of-buffer-external?  

> +  "Open current file or directory with external tools.
> +With prefix argument ARG, open the current `default-directory' instead
> +of the buffer of the current file."

"the file of the current buffer."

> +  (interactive "P")
> +  (let ((browse-url-default-handlers '()))

This is strange.  There are other ways to use an external browser-kind.
Maybe you could use browse-url-secondary-browser-function, which is
"usually an external browser".

> +    (browse-url-of-file
> +     (expand-file-name
> +      (or (and arg ".")
> +          (and (derived-mode-p 'dired-mode)
> +               (dired-get-filename))
> +          buffer-file-name ".")))))




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#69098; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Feb 2024 10:10:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Feb 13 05:10:17 2024
Received: from localhost ([127.0.0.1]:41744 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rZpk0-0004fJ-RH
	for submit <at> debbugs.gnu.org; Tue, 13 Feb 2024 05:10:17 -0500
Received: from lists.gnu.org ([209.51.188.17]:36558)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philipk@HIDDEN>) id 1rZpjy-0004f7-HY
 for submit <at> debbugs.gnu.org; Tue, 13 Feb 2024 05:10:15 -0500
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 <philipk@HIDDEN>)
 id 1rZpjg-00040O-JY
 for bug-gnu-emacs@HIDDEN; Tue, 13 Feb 2024 05:09:56 -0500
Received: from mout01.posteo.de ([185.67.36.65])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philipk@HIDDEN>)
 id 1rZpje-0005MP-TO
 for bug-gnu-emacs@HIDDEN; Tue, 13 Feb 2024 05:09:56 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 185FD240027
 for <bug-gnu-emacs@HIDDEN>; Tue, 13 Feb 2024 11:09:51 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1707818992; bh=Y14+DKCis+wQm6S+v7VBRuWDxbRP7Nf2Xsr714mVOHk=;
 h=From:To:Subject:OpenPGP:Date:Message-ID:MIME-Version:Content-Type:
 From;
 b=o0Gq0xBZ5LS3+EK0eg4UylFSDCQAyzrLDYCsPSG1LxaGW5fr8cRyrBCXmtb+wf7Z9
 HkQJl9NjA6knxPZPiwx1HCwatxwu5Xa6XqDGY3GifE7SZLuGISaSYvL/rvZKqHT2gV
 qFvvJRFGE3SX2hGuluRdEUpKfschCVevZXiiwXsGCylgJAqNrNiP9LoW9PMT31rO23
 EcnHtLKxi/9aeiOratJS7lCLkUHoN0Rup3/bLmYtEjkNq9ARzF8uZIt71YvKrmfv8S
 hEKmNsqpaMQJHBpbrJghSvsUDvfu2UwX6O6NAL2oKwaNGpykFmhaLfIZaERaEKK5+t
 0H+G1G6GJvb+g==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4TYxrv3bwDz6tvq
 for <bug-gnu-emacs@HIDDEN>; Tue, 13 Feb 2024 11:09:51 +0100 (CET)
From: Philip Kaludercic <philipk@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Add new command 'browse-url-here'
OpenPGP: id=7126E1DE2F0CE35C770BED01F2C3CC513DB89F66;
 url="https://keys.openpgp.org/vks/v1/by-fingerprint/7126E1DE2F0CE35C770BED01F2C3CC513DB89F66";
 preference=signencrypt
Date: Tue, 13 Feb 2024 10:09:50 +0000
Message-ID: <87ttmc7k0h.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@HIDDEN;
 helo=mout01.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

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.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Add-new-command-'browse-url-here'.patch
Content-Description: [PATCH] Add new command 'browse-url-here'

From 1f25f653ba35cb2c63a481522ffbf727bc2f5dd3 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@HIDDEN>
Date: Tue, 13 Feb 2024 11:08:09 +0100
Subject: [PATCH] Add new command 'browse-url-here'

* lisp/net/browse-url.el (browse-url-here): Add it.
* etc/NEWS: Document it.
---
 etc/NEWS               |  4 ++++
 lisp/net/browse-url.el | 13 +++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index e7e516d61a1..ea7cd1fc517 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -317,6 +317,10 @@ Previously, it was set to t but this broke remote file name detection.
 ** Multi-character key echo now ends with a suggestion to use Help.
 Customize 'echo-keystrokes-help' to nil to prevent that.
 
+** New command 'browse-url-here'.
+This command opens the current file or directory using an external tool,
+as defined by 'browse-url-of-file'.
+
 
 * Editing Changes in Emacs 30.1
 
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index bc2a7db9a8b..abc1e9e5829 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -943,6 +943,19 @@ browse-url-at-point
 			  browse-url-new-window-flag))
       (error "No URL found"))))
 
+(defun browse-url-here (arg)
+  "Open current file or directory with external tools.
+With prefix argument ARG, open the current `default-directory' instead
+of the buffer of the current file."
+  (interactive "P")
+  (let ((browse-url-default-handlers '()))
+    (browse-url-of-file
+     (expand-file-name
+      (or (and arg ".")
+          (and (derived-mode-p 'dired-mode)
+               (dired-get-filename))
+          buffer-file-name ".")))))
+
 ;;;###autoload
 (defun browse-url-with-browser-kind (kind url &optional arg)
   "Browse URL with a browser of the given browser KIND.
-- 
2.43.0


--=-=-=--




Acknowledgement sent to Philip Kaludercic <philipk@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#69098; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 11 Feb 2025 20:00:02 UTC

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