From: Lars Magne Ingebrigtsen Date: Mon, 10 Nov 2014 20:30:30 +0000 (+0100) Subject: Make `l' and other commands work in eww after going back in history X-Git-Tag: emacs-25.0.90~2635^2~504 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=41d4f8428b65ef57b742cd91d92dcd0a3242d4bd;p=emacs.git 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'. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3a78bb3ee58..3d079103128 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -5,6 +5,11 @@ variables `eww-current-url', `eww-current-dom', `eww-current-source', and `eww-current-title'. + * net/eww.el: Remove `eww-next-url', `eww-previous-url', + `eww-up-url', `eww-home-url', `eww-start-url' and + `eww-contents-url' and put the data into the `eww-data' plist. + This allow restoring these values after going back in the history. + 2014-11-10 Sylvain Chouleur (tiny change) 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'." (defvar eww-history nil) (defvar eww-history-position 0) -(defvar eww-next-url nil) -(defvar eww-previous-url nil) -(defvar eww-up-url nil) -(defvar eww-home-url nil) -(defvar eww-start-url nil) -(defvar eww-contents-url nil) - (defvar eww-local-regex "localhost" "When this regex is found in the URL, it's not a keyword but an address.") @@ -314,23 +307,23 @@ word(s) will be searched for via `eww-search-prefix'." (where (assoc ;; The text associated with :rel is case-insensitive. (if rel (downcase (cdr rel))) - '(("next" . eww-next-url) + '(("next" . :next) ;; Texinfo uses "previous", but HTML specifies ;; "prev", so recognize both. - ("previous" . eww-previous-url) - ("prev" . eww-previous-url) + ("previous" . :previous) + ("prev" . :previous) ;; HTML specifies "start" but also "contents", ;; and Gtk seems to use "home". Recognize ;; them all; but store them in different ;; variables so that we can readily choose the ;; "best" one. - ("start" . eww-start-url) - ("home" . eww-home-url) - ("contents" . eww-contents-url) - ("up" . eww-up-url))))) + ("start" . :start) + ("home" . :home) + ("contents" . :contents) + ("up" . up))))) (and href where - (set (cdr where) (cdr href))))) + (plist-put eww-data (cdr where) (cdr href))))) (defun eww-tag-link (cont) (eww-handle-link cont) @@ -405,13 +398,7 @@ word(s) will be searched for via `eww-search-prefix'." (remove-overlays) (erase-buffer)) (unless (eq major-mode 'eww-mode) - (eww-mode)) - (setq-local eww-next-url nil) - (setq-local eww-previous-url nil) - (setq-local eww-up-url nil) - (setq-local eww-home-url nil) - (setq-local eww-start-url nil) - (setq-local eww-contents-url nil)) + (eww-mode))) (defun eww-view-source () "View the HTML source code of the current page." @@ -604,8 +591,9 @@ the like." A page is marked `next' if rel=\"next\" appears in a or tag." (interactive) - (if eww-next-url - (eww-browse-url (shr-expand-url eww-next-url (plist-get eww-data :url))) + (if (plist-get eww-data :next) + (eww-browse-url (shr-expand-url (plist-get eww-data :next) + (plist-get eww-data :url))) (user-error "No `next' on this page"))) (defun eww-previous-url () @@ -613,8 +601,8 @@ or tag." A page is marked `previous' if rel=\"previous\" appears in a or tag." (interactive) - (if eww-previous-url - (eww-browse-url (shr-expand-url eww-previous-url + (if (plist-get eww-data :previous) + (eww-browse-url (shr-expand-url (plist-get eww-data :previous) (plist-get eww-data :url))) (user-error "No `previous' on this page"))) @@ -623,8 +611,9 @@ or tag." A page is marked `up' if rel=\"up\" appears in a or tag." (interactive) - (if eww-up-url - (eww-browse-url (shr-expand-url eww-up-url (plist-get eww-data :url))) + (if (plist-get eww-data :up) + (eww-browse-url (shr-expand-url (plist-get eww-data :up) + (plist-get eww-data :url))) (user-error "No `up' on this page"))) (defun eww-top-url () @@ -632,9 +621,9 @@ or tag." A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\" appears in a or tag." (interactive) - (let ((best-url (or eww-start-url - eww-contents-url - eww-home-url))) + (let ((best-url (or (plist-get eww-data :start) + (plist-get eww-data :contents) + (plist-get eww-data :home)))) (if best-url (eww-browse-url (shr-expand-url best-url (plist-get eww-data :url))) (user-error "No `top' for this page"))))