diff options
| author | Lars Magne Ingebrigtsen | 2014-11-10 21:30:30 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-11-10 21:30:30 +0100 |
| commit | 41d4f8428b65ef57b742cd91d92dcd0a3242d4bd (patch) | |
| tree | d6414757d0688b8696c7f16c8b42b99d47da653a | |
| parent | 02b99d23046adbe1b81b95e5f738786f606ed046 (diff) | |
| download | emacs-41d4f8428b65ef57b742cd91d92dcd0a3242d4bd.tar.gz emacs-41d4f8428b65ef57b742cd91d92dcd0a3242d4bd.zip | |
Make `l' and other commands work in eww after going back in history
* net/eww.el (eww-data): New plist to store all the data relevant
to a single page, used throughout the file instead of the
variables `eww-current-url', `eww-current-dom',
`eww-current-source', and `eww-current-title'.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/net/eww.el | 51 |
2 files changed, 25 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3a78bb3ee58..3d079103128 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -5,6 +5,11 @@ | |||
| 5 | variables `eww-current-url', `eww-current-dom', | 5 | variables `eww-current-url', `eww-current-dom', |
| 6 | `eww-current-source', and `eww-current-title'. | 6 | `eww-current-source', and `eww-current-title'. |
| 7 | 7 | ||
| 8 | * net/eww.el: Remove `eww-next-url', `eww-previous-url', | ||
| 9 | `eww-up-url', `eww-home-url', `eww-start-url' and | ||
| 10 | `eww-contents-url' and put the data into the `eww-data' plist. | ||
| 11 | This allow restoring these values after going back in the history. | ||
| 12 | |||
| 8 | 2014-11-10 Sylvain Chouleur <sylvain.chouleur@gmail.com> (tiny change) | 13 | 2014-11-10 Sylvain Chouleur <sylvain.chouleur@gmail.com> (tiny change) |
| 9 | 14 | ||
| 10 | Allow VTIMEZONE where daylight and standard time zones are equal. | 15 | Allow VTIMEZONE where daylight and standard time zones are equal. |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 7d21f3ac688..2ad3980e8d9 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -136,13 +136,6 @@ See also `eww-form-checkbox-selected-symbol'." | |||
| 136 | (defvar eww-history nil) | 136 | (defvar eww-history nil) |
| 137 | (defvar eww-history-position 0) | 137 | (defvar eww-history-position 0) |
| 138 | 138 | ||
| 139 | (defvar eww-next-url nil) | ||
| 140 | (defvar eww-previous-url nil) | ||
| 141 | (defvar eww-up-url nil) | ||
| 142 | (defvar eww-home-url nil) | ||
| 143 | (defvar eww-start-url nil) | ||
| 144 | (defvar eww-contents-url nil) | ||
| 145 | |||
| 146 | (defvar eww-local-regex "localhost" | 139 | (defvar eww-local-regex "localhost" |
| 147 | "When this regex is found in the URL, it's not a keyword but an address.") | 140 | "When this regex is found in the URL, it's not a keyword but an address.") |
| 148 | 141 | ||
| @@ -314,23 +307,23 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 314 | (where (assoc | 307 | (where (assoc |
| 315 | ;; The text associated with :rel is case-insensitive. | 308 | ;; The text associated with :rel is case-insensitive. |
| 316 | (if rel (downcase (cdr rel))) | 309 | (if rel (downcase (cdr rel))) |
| 317 | '(("next" . eww-next-url) | 310 | '(("next" . :next) |
| 318 | ;; Texinfo uses "previous", but HTML specifies | 311 | ;; Texinfo uses "previous", but HTML specifies |
| 319 | ;; "prev", so recognize both. | 312 | ;; "prev", so recognize both. |
| 320 | ("previous" . eww-previous-url) | 313 | ("previous" . :previous) |
| 321 | ("prev" . eww-previous-url) | 314 | ("prev" . :previous) |
| 322 | ;; HTML specifies "start" but also "contents", | 315 | ;; HTML specifies "start" but also "contents", |
| 323 | ;; and Gtk seems to use "home". Recognize | 316 | ;; and Gtk seems to use "home". Recognize |
| 324 | ;; them all; but store them in different | 317 | ;; them all; but store them in different |
| 325 | ;; variables so that we can readily choose the | 318 | ;; variables so that we can readily choose the |
| 326 | ;; "best" one. | 319 | ;; "best" one. |
| 327 | ("start" . eww-start-url) | 320 | ("start" . :start) |
| 328 | ("home" . eww-home-url) | 321 | ("home" . :home) |
| 329 | ("contents" . eww-contents-url) | 322 | ("contents" . :contents) |
| 330 | ("up" . eww-up-url))))) | 323 | ("up" . up))))) |
| 331 | (and href | 324 | (and href |
| 332 | where | 325 | where |
| 333 | (set (cdr where) (cdr href))))) | 326 | (plist-put eww-data (cdr where) (cdr href))))) |
| 334 | 327 | ||
| 335 | (defun eww-tag-link (cont) | 328 | (defun eww-tag-link (cont) |
| 336 | (eww-handle-link cont) | 329 | (eww-handle-link cont) |
| @@ -405,13 +398,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 405 | (remove-overlays) | 398 | (remove-overlays) |
| 406 | (erase-buffer)) | 399 | (erase-buffer)) |
| 407 | (unless (eq major-mode 'eww-mode) | 400 | (unless (eq major-mode 'eww-mode) |
| 408 | (eww-mode)) | 401 | (eww-mode))) |
| 409 | (setq-local eww-next-url nil) | ||
| 410 | (setq-local eww-previous-url nil) | ||
| 411 | (setq-local eww-up-url nil) | ||
| 412 | (setq-local eww-home-url nil) | ||
| 413 | (setq-local eww-start-url nil) | ||
| 414 | (setq-local eww-contents-url nil)) | ||
| 415 | 402 | ||
| 416 | (defun eww-view-source () | 403 | (defun eww-view-source () |
| 417 | "View the HTML source code of the current page." | 404 | "View the HTML source code of the current page." |
| @@ -604,8 +591,9 @@ the like." | |||
| 604 | A page is marked `next' if rel=\"next\" appears in a <link> | 591 | A page is marked `next' if rel=\"next\" appears in a <link> |
| 605 | or <a> tag." | 592 | or <a> tag." |
| 606 | (interactive) | 593 | (interactive) |
| 607 | (if eww-next-url | 594 | (if (plist-get eww-data :next) |
| 608 | (eww-browse-url (shr-expand-url eww-next-url (plist-get eww-data :url))) | 595 | (eww-browse-url (shr-expand-url (plist-get eww-data :next) |
| 596 | (plist-get eww-data :url))) | ||
| 609 | (user-error "No `next' on this page"))) | 597 | (user-error "No `next' on this page"))) |
| 610 | 598 | ||
| 611 | (defun eww-previous-url () | 599 | (defun eww-previous-url () |
| @@ -613,8 +601,8 @@ or <a> tag." | |||
| 613 | A page is marked `previous' if rel=\"previous\" appears in a <link> | 601 | A page is marked `previous' if rel=\"previous\" appears in a <link> |
| 614 | or <a> tag." | 602 | or <a> tag." |
| 615 | (interactive) | 603 | (interactive) |
| 616 | (if eww-previous-url | 604 | (if (plist-get eww-data :previous) |
| 617 | (eww-browse-url (shr-expand-url eww-previous-url | 605 | (eww-browse-url (shr-expand-url (plist-get eww-data :previous) |
| 618 | (plist-get eww-data :url))) | 606 | (plist-get eww-data :url))) |
| 619 | (user-error "No `previous' on this page"))) | 607 | (user-error "No `previous' on this page"))) |
| 620 | 608 | ||
| @@ -623,8 +611,9 @@ or <a> tag." | |||
| 623 | A page is marked `up' if rel=\"up\" appears in a <link> | 611 | A page is marked `up' if rel=\"up\" appears in a <link> |
| 624 | or <a> tag." | 612 | or <a> tag." |
| 625 | (interactive) | 613 | (interactive) |
| 626 | (if eww-up-url | 614 | (if (plist-get eww-data :up) |
| 627 | (eww-browse-url (shr-expand-url eww-up-url (plist-get eww-data :url))) | 615 | (eww-browse-url (shr-expand-url (plist-get eww-data :up) |
| 616 | (plist-get eww-data :url))) | ||
| 628 | (user-error "No `up' on this page"))) | 617 | (user-error "No `up' on this page"))) |
| 629 | 618 | ||
| 630 | (defun eww-top-url () | 619 | (defun eww-top-url () |
| @@ -632,9 +621,9 @@ or <a> tag." | |||
| 632 | A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\" | 621 | A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\" |
| 633 | appears in a <link> or <a> tag." | 622 | appears in a <link> or <a> tag." |
| 634 | (interactive) | 623 | (interactive) |
| 635 | (let ((best-url (or eww-start-url | 624 | (let ((best-url (or (plist-get eww-data :start) |
| 636 | eww-contents-url | 625 | (plist-get eww-data :contents) |
| 637 | eww-home-url))) | 626 | (plist-get eww-data :home)))) |
| 638 | (if best-url | 627 | (if best-url |
| 639 | (eww-browse-url (shr-expand-url best-url (plist-get eww-data :url))) | 628 | (eww-browse-url (shr-expand-url best-url (plist-get eww-data :url))) |
| 640 | (user-error "No `top' for this page")))) | 629 | (user-error "No `top' for this page")))) |