From bcf4913e0619c2778b75b96e9628661e3d8260c3 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 Dec 2015 11:54:18 +0200 Subject: [PATCH] Allow 'browse-url-emacs' visit non-existent URLs * lisp/url/url-handlers.el (url-insert-file-contents): Don't signal an error if VISIT is non-nil, to more faithfully emulate the behavior of 'insert-file-contents'. (Bug#22160) --- lisp/url/url-handlers.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el index bafe3e52725..0b9d43f70cf 100644 --- a/lisp/url/url-handlers.el +++ b/lisp/url/url-handlers.el @@ -340,8 +340,15 @@ if it had been inserted from a file named URL." ;; XXX: This is HTTP/S specific and should be moved to url-http ;; instead. See http://debbugs.gnu.org/17549. (when (bound-and-true-p url-http-response-status) - (unless (and (>= url-http-response-status 200) - (< url-http-response-status 300)) + ;; Don't signal an error if VISIT is non-nil, because + ;; 'insert-file-contents' doesn't. This is required to + ;; support, e.g., 'browse-url-emacs', which is a fancy way of + ;; visiting the HTML source of a URL: in that case, we want to + ;; display a file buffer even if the URL does not exist and + ;; 'url-retrieve-synchronously' returns 404 or whatever. + (unless (or visit + (and (>= url-http-response-status 200) + (< url-http-response-status 300))) (let ((desc (nth 2 (assq url-http-response-status url-http-codes)))) (kill-buffer buffer) ;; Signal file-error per http://debbugs.gnu.org/16733. -- 2.39.2