diff options
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/net/eww.el | 19 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30bbe57f352..ff93f0489c2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2013-12-05 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * net/eww.el (eww-current-source): New variable to store page | ||
| 4 | source. | ||
| 5 | (eww-display-html, eww-mode, eww-save-history) | ||
| 6 | (eww-restore-history): Use it. | ||
| 7 | (eww-view-source): New command to view page source. | ||
| 8 | Opportunistically uses `html-mode' to highlight the buffer. | ||
| 9 | (eww-mode-map): Install it. | ||
| 10 | |||
| 1 | 2013-12-05 Michael Albinus <michael.albinus@gmx.de> | 11 | 2013-12-05 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 12 | ||
| 3 | * net/dbus.el (dbus-unregister-service) | 13 | * net/dbus.el (dbus-unregister-service) |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 6c6ef8a20aa..9d1c3a26949 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -117,6 +117,7 @@ See also `eww-form-checkbox-selected-symbol'." | |||
| 117 | 117 | ||
| 118 | (defvar eww-current-url nil) | 118 | (defvar eww-current-url nil) |
| 119 | (defvar eww-current-dom nil) | 119 | (defvar eww-current-dom nil) |
| 120 | (defvar eww-current-source nil) | ||
| 120 | (defvar eww-current-title "" | 121 | (defvar eww-current-title "" |
| 121 | "Title of current page.") | 122 | "Title of current page.") |
| 122 | (defvar eww-history nil) | 123 | (defvar eww-history nil) |
| @@ -247,6 +248,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 247 | (list | 248 | (list |
| 248 | 'base (list (cons 'href url)) | 249 | 'base (list (cons 'href url)) |
| 249 | (libxml-parse-html-region (point) (point-max)))))) | 250 | (libxml-parse-html-region (point) (point-max)))))) |
| 251 | (setq eww-current-source (buffer-substring (point) (point-max))) | ||
| 250 | (eww-setup-buffer) | 252 | (eww-setup-buffer) |
| 251 | (setq eww-current-dom document) | 253 | (setq eww-current-dom document) |
| 252 | (let ((inhibit-read-only t) | 254 | (let ((inhibit-read-only t) |
| @@ -375,6 +377,18 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 375 | (unless (eq major-mode 'eww-mode) | 377 | (unless (eq major-mode 'eww-mode) |
| 376 | (eww-mode))) | 378 | (eww-mode))) |
| 377 | 379 | ||
| 380 | (defun eww-view-source () | ||
| 381 | (interactive) | ||
| 382 | (let ((buf (get-buffer-create "*eww-source*")) | ||
| 383 | (source eww-current-source)) | ||
| 384 | (with-current-buffer buf | ||
| 385 | (delete-region (point-min) (point-max)) | ||
| 386 | (insert (or eww-current-source "no source")) | ||
| 387 | (goto-char (point-min)) | ||
| 388 | (when (featurep 'html-mode) | ||
| 389 | (html-mode))) | ||
| 390 | (view-buffer buf))) | ||
| 391 | |||
| 378 | (defvar eww-mode-map | 392 | (defvar eww-mode-map |
| 379 | (let ((map (make-sparse-keymap))) | 393 | (let ((map (make-sparse-keymap))) |
| 380 | (suppress-keymap map) | 394 | (suppress-keymap map) |
| @@ -395,6 +409,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 395 | (define-key map "d" 'eww-download) | 409 | (define-key map "d" 'eww-download) |
| 396 | (define-key map "w" 'eww-copy-page-url) | 410 | (define-key map "w" 'eww-copy-page-url) |
| 397 | (define-key map "C" 'url-cookie-list) | 411 | (define-key map "C" 'url-cookie-list) |
| 412 | (define-key map "v" 'eww-view-source) | ||
| 398 | 413 | ||
| 399 | (define-key map "b" 'eww-add-bookmark) | 414 | (define-key map "b" 'eww-add-bookmark) |
| 400 | (define-key map "B" 'eww-list-bookmarks) | 415 | (define-key map "B" 'eww-list-bookmarks) |
| @@ -411,6 +426,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 411 | :active (not (zerop eww-history-position))] | 426 | :active (not (zerop eww-history-position))] |
| 412 | ["Browse with external browser" eww-browse-with-external-browser t] | 427 | ["Browse with external browser" eww-browse-with-external-browser t] |
| 413 | ["Download" eww-download t] | 428 | ["Download" eww-download t] |
| 429 | ["View page source" eww-view-source] | ||
| 414 | ["Copy page URL" eww-copy-page-url t] | 430 | ["Copy page URL" eww-copy-page-url t] |
| 415 | ["Add bookmark" eww-add-bookmark t] | 431 | ["Add bookmark" eww-add-bookmark t] |
| 416 | ["List bookmarks" eww-copy-page-url t] | 432 | ["List bookmarks" eww-copy-page-url t] |
| @@ -424,6 +440,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 424 | ;; FIXME? This seems a strange default. | 440 | ;; FIXME? This seems a strange default. |
| 425 | (set (make-local-variable 'eww-current-url) 'author) | 441 | (set (make-local-variable 'eww-current-url) 'author) |
| 426 | (set (make-local-variable 'eww-current-dom) nil) | 442 | (set (make-local-variable 'eww-current-dom) nil) |
| 443 | (set (make-local-variable 'eww-current-source) nil) | ||
| 427 | (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url) | 444 | (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url) |
| 428 | (set (make-local-variable 'after-change-functions) 'eww-process-text-input) | 445 | (set (make-local-variable 'after-change-functions) 'eww-process-text-input) |
| 429 | (set (make-local-variable 'eww-history) nil) | 446 | (set (make-local-variable 'eww-history) nil) |
| @@ -437,6 +454,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 437 | :title eww-current-title | 454 | :title eww-current-title |
| 438 | :point (point) | 455 | :point (point) |
| 439 | :dom eww-current-dom | 456 | :dom eww-current-dom |
| 457 | :source eww-current-source | ||
| 440 | :text (buffer-string)) | 458 | :text (buffer-string)) |
| 441 | eww-history)) | 459 | eww-history)) |
| 442 | 460 | ||
| @@ -468,6 +486,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 468 | (let ((inhibit-read-only t)) | 486 | (let ((inhibit-read-only t)) |
| 469 | (erase-buffer) | 487 | (erase-buffer) |
| 470 | (insert (plist-get elem :text)) | 488 | (insert (plist-get elem :text)) |
| 489 | (setq eww-current-source (plist-get elem :source)) | ||
| 471 | (setq eww-current-dom (plist-get elem :dom)) | 490 | (setq eww-current-dom (plist-get elem :dom)) |
| 472 | (goto-char (plist-get elem :point)) | 491 | (goto-char (plist-get elem :point)) |
| 473 | (setq eww-current-url (plist-get elem :url) | 492 | (setq eww-current-url (plist-get elem :url) |