diff options
| author | Lars Magne Ingebrigtsen | 2014-11-10 22:18:11 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-11-10 22:18:11 +0100 |
| commit | 14fe3679c9b26b29872525c85f3278ecb50c8eac (patch) | |
| tree | 4d29ae89005ac6db2ba8515e73fc3fbdfaa837d3 | |
| parent | df87fc30e19588e6c5811ab2dd02c7fd046a8e88 (diff) | |
| download | emacs-14fe3679c9b26b29872525c85f3278ecb50c8eac.tar.gz emacs-14fe3679c9b26b29872525c85f3278ecb50c8eac.zip | |
Allow using several eww buffers (bug#16211)
* net/eww.el (eww-render, eww-display-html, eww-setup-buffer):
Allow taking a buffer to render data in. This allows using several
eww buffers (bug#16211).
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/eww.el | 38 |
4 files changed, 36 insertions, 15 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog index d8042977168..c2ed06ca523 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-11-10 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * NEWS: Mention that you can have several eww buffers (bug#16211). | ||
| 4 | |||
| 1 | 2014-11-10 Glenn Morris <rgm@gnu.org> | 5 | 2014-11-10 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * refcards/emacsver.tex.in: Rename from emacsver.tex. | 7 | * refcards/emacsver.tex.in: Rename from emacsver.tex. |
| @@ -153,6 +153,9 @@ result of the calculation into the current buffer. | |||
| 153 | textual parts of a web page and display only that, leaving menus and | 153 | textual parts of a web page and display only that, leaving menus and |
| 154 | the like off the page. | 154 | the like off the page. |
| 155 | 155 | ||
| 156 | *** You can now use several eww buffers in parallel by renaming eww | ||
| 157 | buffers you want to keep separate. | ||
| 158 | |||
| 156 | ** Message mode | 159 | ** Message mode |
| 157 | 160 | ||
| 158 | *** text/html messages that contain inline image parts will be | 161 | *** text/html messages that contain inline image parts will be |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7cd867dd7da..efa44b009cb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-11-10 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * net/eww.el (eww-render, eww-display-html, eww-setup-buffer): | ||
| 4 | Allow taking a buffer to render data in. This allows using several | ||
| 5 | eww buffers (bug#16211). | ||
| 6 | |||
| 1 | 2014-11-10 Charles Rendleman <carendle@gmail.com> (tiny change) | 7 | 2014-11-10 Charles Rendleman <carendle@gmail.com> (tiny change) |
| 2 | 8 | ||
| 3 | * net/eww.el (eww-download-callback): Save only the file contents, | 9 | * net/eww.el (eww-download-callback): Save only the file contents, |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index f6ab07801c7..b867134db00 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -167,7 +167,10 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 167 | (setq url (concat url "/")))) | 167 | (setq url (concat url "/")))) |
| 168 | (setq url (concat eww-search-prefix | 168 | (setq url (concat eww-search-prefix |
| 169 | (replace-regexp-in-string " " "+" url)))))) | 169 | (replace-regexp-in-string " " "+" url)))))) |
| 170 | (url-retrieve url 'eww-render (list url))) | 170 | (url-retrieve url 'eww-render |
| 171 | (list url nil | ||
| 172 | (and (eq major-mode 'eww-mode) | ||
| 173 | (current-buffer))))) | ||
| 171 | 174 | ||
| 172 | ;;;###autoload (defalias 'browse-web 'eww) | 175 | ;;;###autoload (defalias 'browse-web 'eww) |
| 173 | 176 | ||
| @@ -180,7 +183,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 180 | "/") | 183 | "/") |
| 181 | (expand-file-name file)))) | 184 | (expand-file-name file)))) |
| 182 | 185 | ||
| 183 | (defun eww-render (status url &optional point) | 186 | (defun eww-render (status url &optional point buffer) |
| 184 | (let ((redirect (plist-get status :redirect))) | 187 | (let ((redirect (plist-get status :redirect))) |
| 185 | (when redirect | 188 | (when redirect |
| 186 | (setq url redirect))) | 189 | (setq url redirect))) |
| @@ -205,14 +208,14 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 205 | (car content-type))) | 208 | (car content-type))) |
| 206 | (eww-browse-with-external-browser url)) | 209 | (eww-browse-with-external-browser url)) |
| 207 | ((equal (car content-type) "text/html") | 210 | ((equal (car content-type) "text/html") |
| 208 | (eww-display-html charset url nil point)) | 211 | (eww-display-html charset url nil point buffer)) |
| 209 | ((equal (car content-type) "application/pdf") | 212 | ((equal (car content-type) "application/pdf") |
| 210 | (eww-display-pdf)) | 213 | (eww-display-pdf)) |
| 211 | ((string-match-p "\\`image/" (car content-type)) | 214 | ((string-match-p "\\`image/" (car content-type)) |
| 212 | (eww-display-image) | 215 | (eww-display-image buffer) |
| 213 | (eww-update-header-line-format)) | 216 | (eww-update-header-line-format)) |
| 214 | (t | 217 | (t |
| 215 | (eww-display-raw) | 218 | (eww-display-raw buffer) |
| 216 | (eww-update-header-line-format))) | 219 | (eww-update-header-line-format))) |
| 217 | (plist-put eww-data :title url) | 220 | (plist-put eww-data :title url) |
| 218 | (setq eww-history-position 0)) | 221 | (setq eww-history-position 0)) |
| @@ -247,7 +250,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 247 | (declare-function libxml-parse-html-region "xml.c" | 250 | (declare-function libxml-parse-html-region "xml.c" |
| 248 | (start end &optional base-url)) | 251 | (start end &optional base-url)) |
| 249 | 252 | ||
| 250 | (defun eww-display-html (charset url &optional document point) | 253 | (defun eww-display-html (charset url &optional document point buffer) |
| 251 | (or (fboundp 'libxml-parse-html-region) | 254 | (or (fboundp 'libxml-parse-html-region) |
| 252 | (error "This function requires Emacs to be compiled with libxml2")) | 255 | (error "This function requires Emacs to be compiled with libxml2")) |
| 253 | ;; There should be a better way to abort loading images | 256 | ;; There should be a better way to abort loading images |
| @@ -265,7 +268,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 265 | (libxml-parse-html-region (point) (point-max)))))) | 268 | (libxml-parse-html-region (point) (point-max)))))) |
| 266 | (source (and (null document) | 269 | (source (and (null document) |
| 267 | (buffer-substring (point) (point-max))))) | 270 | (buffer-substring (point) (point-max))))) |
| 268 | (eww-setup-buffer) | 271 | (eww-setup-buffer buffer) |
| 269 | (plist-put eww-data :source source) | 272 | (plist-put eww-data :source source) |
| 270 | (plist-put eww-data :dom document) | 273 | (plist-put eww-data :dom document) |
| 271 | (let ((inhibit-read-only t) | 274 | (let ((inhibit-read-only t) |
| @@ -368,16 +371,16 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 368 | (shr-generic cont) | 371 | (shr-generic cont) |
| 369 | (shr-colorize-region start (point) fgcolor bgcolor))) | 372 | (shr-colorize-region start (point) fgcolor bgcolor))) |
| 370 | 373 | ||
| 371 | (defun eww-display-raw () | 374 | (defun eww-display-raw (&optional buffer) |
| 372 | (let ((data (buffer-substring (point) (point-max)))) | 375 | (let ((data (buffer-substring (point) (point-max)))) |
| 373 | (eww-setup-buffer) | 376 | (eww-setup-buffer buffer) |
| 374 | (let ((inhibit-read-only t)) | 377 | (let ((inhibit-read-only t)) |
| 375 | (insert data)) | 378 | (insert data)) |
| 376 | (goto-char (point-min)))) | 379 | (goto-char (point-min)))) |
| 377 | 380 | ||
| 378 | (defun eww-display-image () | 381 | (defun eww-display-image (&optional buffer) |
| 379 | (let ((data (shr-parse-image-data))) | 382 | (let ((data (shr-parse-image-data))) |
| 380 | (eww-setup-buffer) | 383 | (eww-setup-buffer buffer) |
| 381 | (let ((inhibit-read-only t)) | 384 | (let ((inhibit-read-only t)) |
| 382 | (shr-put-image data nil)) | 385 | (shr-put-image data nil)) |
| 383 | (goto-char (point-min)))) | 386 | (goto-char (point-min)))) |
| @@ -392,8 +395,11 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 392 | (doc-view-mode))) | 395 | (doc-view-mode))) |
| 393 | (goto-char (point-min))) | 396 | (goto-char (point-min))) |
| 394 | 397 | ||
| 395 | (defun eww-setup-buffer () | 398 | (defun eww-setup-buffer (&optional buffer) |
| 396 | (switch-to-buffer (get-buffer-create "*eww*")) | 399 | (switch-to-buffer |
| 400 | (if (buffer-live-p buffer) | ||
| 401 | buffer | ||
| 402 | (get-buffer-create "*eww*"))) | ||
| 397 | (let ((inhibit-read-only t)) | 403 | (let ((inhibit-read-only t)) |
| 398 | (remove-overlays) | 404 | (remove-overlays) |
| 399 | (erase-buffer)) | 405 | (erase-buffer)) |
| @@ -431,7 +437,8 @@ the like." | |||
| 431 | (eww-save-history) | 437 | (eww-save-history) |
| 432 | (eww-display-html nil nil | 438 | (eww-display-html nil nil |
| 433 | (shr-retransform-dom | 439 | (shr-retransform-dom |
| 434 | (eww-highest-readability dom))) | 440 | (eww-highest-readability dom)) |
| 441 | nil (current-buffer)) | ||
| 435 | (dolist (elem '(:source :url :title :next :previous :up)) | 442 | (dolist (elem '(:source :url :title :next :previous :up)) |
| 436 | (plist-put eww-data elem (plist-get old-data elem))) | 443 | (plist-put eww-data elem (plist-get old-data elem))) |
| 437 | (eww-update-header-line-format))) | 444 | (eww-update-header-line-format))) |
| @@ -1110,7 +1117,8 @@ If EXTERNAL, browse the URL using `shr-external-browser'." | |||
| 1110 | ((and (url-target (url-generic-parse-url url)) | 1117 | ((and (url-target (url-generic-parse-url url)) |
| 1111 | (eww-same-page-p url (plist-get eww-data :url))) | 1118 | (eww-same-page-p url (plist-get eww-data :url))) |
| 1112 | (eww-save-history) | 1119 | (eww-save-history) |
| 1113 | (eww-display-html 'utf-8 url (plist-get eww-data :url))) | 1120 | (eww-display-html 'utf-8 url (plist-get eww-data :url) |
| 1121 | nil (current-buffer))) | ||
| 1114 | (t | 1122 | (t |
| 1115 | (eww-browse-url url))))) | 1123 | (eww-browse-url url))))) |
| 1116 | 1124 | ||