]> code.delx.au - gnu-emacs/blobdiff - lisp/url/url-handlers.el
Merge branch 'emacs-25-merge'
[gnu-emacs] / lisp / url / url-handlers.el
index d13df6945a7834e1b02c61613c1d8f30e3b71c14..9c27276785892170bd1165763714df45889c3afa 100644 (file)
@@ -269,7 +269,8 @@ A prefix arg makes KEEP-TIME non-nil."
        (error "Opening input file: No such file or directory, %s" url))
     (with-current-buffer buffer
       (setq handle (mm-dissect-buffer t)))
-    (mm-save-part-to-file handle newname)
+    (let ((mm-attachment-file-modes (default-file-modes)))
+      (mm-save-part-to-file handle newname))
     (kill-buffer buffer)
     (mm-destroy-parts handle)))
 (put 'copy-file 'url-file-handlers 'url-copy-file)
@@ -341,8 +342,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.