(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)
;; 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.