unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Gillespie <tgbugs@gmail.com>
To: emacs-devel@gnu.org
Subject: [PATCH] lisp/net/browse-url.el allow fragments in file: urls
Date: Wed, 31 Mar 2021 19:16:32 -0700	[thread overview]
Message-ID: <CA+G3_PN-vSetiVmtY8Ewj3Cuu1LqhVZrWNP3mFeKLDcmBp-qCQ@mail.gmail.com> (raw)

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

This fixes the current behavior of browse-url--non-html-file-url-p and
makes it possible to open file:// urls that end with a #fragment. The
current behavior results in a nasty side effect where opening a file
with browse-url-emacs that has a fragment causes any invocation of
call-process to fail because the fragment is not handled correctly.

Best!
Tom

[-- Attachment #2: 0001-lisp-net-browse-url.el-allow-fragments-in-file-urls.patch --]
[-- Type: text/x-patch, Size: 987 bytes --]

From a557f1b9ee397f93ca6b56c1fcc36896e6b4fafc Mon Sep 17 00:00:00 2001
From: Tom Gillespie <tgbugs@gmail.com>
Date: Wed, 31 Mar 2021 18:50:49 -0700
Subject: [PATCH] lisp/net/browse-url.el allow fragments in file:// urls

* lisp/net/browse-url.el (browse-url--non-html-file-url-p): Update
regexp to match file:// urls that end in a fragment.
---
 lisp/net/browse-url.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 1c98335a20..aef221e9d7 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -617,7 +617,7 @@ browse-url--browser-kind-browser
 (defun browse-url--non-html-file-url-p (url)
   "Return non-nil if URL is a file:// URL of a non-HTML file."
   (and (string-match-p "\\`file://" url)
-       (not (string-match-p "\\`file://.*\\.html?\\b" url))))
+       (not (string-match-p "\\`file://.*\\.html?\\(#.*\\)?\\b" url))))
 
 ;;;###autoload
 (defvar browse-url-default-handlers
-- 
2.26.3


             reply	other threads:[~2021-04-01  2:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  2:16 Tom Gillespie [this message]
2021-04-01  7:20 ` [PATCH] lisp/net/browse-url.el allow fragments in file: urls Eli Zaretskii
2021-04-02  0:22   ` Tom Gillespie
2021-04-02  5:43     ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CA+G3_PN-vSetiVmtY8Ewj3Cuu1LqhVZrWNP3mFeKLDcmBp-qCQ@mail.gmail.com \
    --to=tgbugs@gmail.com \
    --cc=emacs-devel@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 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).