summaryrefslogtreecommitdiff
path: root/lisp/net/eww.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-02-20 15:52:10 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2022-02-20 16:14:05 +0100
commitaa6d1027ce08f9827dcf7d3a2286f94ea1a283cb (patch)
tree409d7d1b88ff6950278b1a2b8362ff6dc2f28153 /lisp/net/eww.el
parentd710b8422547cf7c0e222408a2ca660cd6ce40b6 (diff)
downloademacs-aa6d1027ce08f9827dcf7d3a2286f94ea1a283cb.tar.gz
emacs-aa6d1027ce08f9827dcf7d3a2286f94ea1a283cb.tar.bz2
emacs-aa6d1027ce08f9827dcf7d3a2286f94ea1a283cb.zip
Make `g' work in eww buffers displaying Tramp files
* lisp/net/eww.el (eww--file-buffer): Refactored out. (eww-open-file): From here. (eww-reload): Make reloading work in Tramp files.
Diffstat (limited to 'lisp/net/eww.el')
-rw-r--r--lisp/net/eww.el32
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 9db07b51dbd..cfebb108a5b 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -495,14 +495,17 @@ killed after rendering."
;; The file name may be a non-local Tramp file. The URL
;; library doesn't understand these file names, so use the
;; normal Emacs machinery to load the file.
- (with-current-buffer (generate-new-buffer " *eww file*")
- (set-buffer-multibyte nil)
- (insert "Content-type: " (or (mailcap-extension-to-mime
- (url-file-extension file))
- "application/octet-stream")
- "\n\n")
- (insert-file-contents file)
- (current-buffer))))
+ (eww--file-buffer file)))
+
+(defun eww--file-buffer (file)
+ (with-current-buffer (generate-new-buffer " *eww file*")
+ (set-buffer-multibyte nil)
+ (insert "Content-type: " (or (mailcap-extension-to-mime
+ (url-file-extension file))
+ "application/octet-stream")
+ "\n\n")
+ (insert-file-contents file)
+ (current-buffer)))
;;;###autoload
(defun eww-search-words ()
@@ -1291,9 +1294,16 @@ just re-display the HTML already fetched."
(error "No current HTML data")
(eww-display-html 'utf-8 url (plist-get eww-data :dom)
(point) (current-buffer)))
- (let ((url-mime-accept-string eww-accept-content-types))
- (eww-retrieve url #'eww-render
- (list url (point) (current-buffer) encode))))))
+ (let ((parsed (url-generic-parse-url url)))
+ (if (equal (url-type parsed) "file")
+ ;; Use Tramp instead of url.el for files (since url.el
+ ;; doesn't work well with Tramp files).
+ (let ((eww-buffer (current-buffer)))
+ (with-current-buffer (eww--file-buffer (url-filename parsed))
+ (eww-render nil url nil eww-buffer)))
+ (let ((url-mime-accept-string eww-accept-content-types))
+ (eww-retrieve url #'eww-render
+ (list url (point) (current-buffer) encode))))))))
;; Form support.