all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: 55357@debbugs.gnu.org
Subject: bug#55357: 29.0.50; [PATCH] Fix browse-url-emacs on file:// urls
Date: Wed, 11 May 2022 00:05:50 -0700	[thread overview]
Message-ID: <CB9DF870-93DB-477E-8E42-A08DA3699B6F@gmail.com> (raw)

[-- 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))

             reply	other threads:[~2022-05-11  7:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11  7:05 Yuan Fu [this message]
2022-05-11  7:53 ` bug#55357: 29.0.50; [PATCH] Fix browse-url-emacs on file:// urls Andreas Schwab
2022-05-11 11:37 ` Eli Zaretskii
2022-05-11 18:35   ` Yuan Fu
2022-05-11 18:35     ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CB9DF870-93DB-477E-8E42-A08DA3699B6F@gmail.com \
    --to=casouri@gmail.com \
    --cc=55357@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.