unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55357: 29.0.50; [PATCH] Fix browse-url-emacs on file:// urls
@ 2022-05-11  7:05 Yuan Fu
  2022-05-11  7:53 ` Andreas Schwab
  2022-05-11 11:37 ` Eli Zaretskii
  0 siblings, 2 replies; 5+ messages in thread
From: Yuan Fu @ 2022-05-11  7:05 UTC (permalink / raw)
  To: 55357

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]


If you call browse-url-emacs with a file:// url, Emacs does not open the correct file:

(browse-url-emacs "file://~/a/b") opens /a/b
(browse-url-emacs "file://a/b") opens /b

Basically unless the path is an absolute path, the first level is chopped because url parses it as host and throws it away. This patch concats the host back. If the path is absolute, host is empty string so it’s ok.

Yuan


[-- Attachment #2: file-url.patch --]
[-- Type: application/octet-stream, Size: 714 bytes --]

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 66898d7707..393ed76e8b 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -1250,7 +1250,9 @@ browse-url-emacs
         (func (if same-window 'find-file 'find-file-other-window)))
     (if (equal (url-type parsed) "file")
         ;; It's a file; just open it.
-        (let ((file (url-unhex-string (url-filename parsed))))
+        (let ((file (url-unhex-string
+                     (concat (url-host parsed)
+                             (url-filename parsed)))))
           (when-let ((coding (browse-url--file-name-coding-system)))
             (setq file (decode-coding-string file 'utf-8)))
           (funcall func file))

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-11 18:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  7:05 bug#55357: 29.0.50; [PATCH] Fix browse-url-emacs on file:// urls Yuan Fu
2022-05-11  7:53 ` Andreas Schwab
2022-05-11 11:37 ` Eli Zaretskii
2022-05-11 18:35   ` Yuan Fu
2022-05-11 18:35     ` Yuan Fu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).