emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113180: * net/eww.el: Rework history traversal.


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] trunk r113180: * net/eww.el: Rework history traversal.
Date: Tue, 25 Jun 2013 22:24:47 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113180
revision-id: address@hidden
parent: address@hidden
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Wed 2013-06-26 00:24:43 +0200
message:
  * net/eww.el: Rework history traversal.
  
  When going forward/back, put these actions into the history, too, so
  that they can be replayed.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/eww.el                eww.el-20130610114603-80ap3gwnw4x4m5ix-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-06-25 20:48:54 +0000
+++ b/lisp/ChangeLog    2013-06-25 22:24:43 +0000
@@ -1,3 +1,9 @@
+2013-06-25  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * net/eww.el: Rework history traversal.  When going forward/back,
+       put these actions into the history, too, so that they can be
+       replayed.
+
 2013-06-25  Juri Linkov  <address@hidden>
 
        * files-x.el (modify-dir-local-variable): Change the header comment

=== modified file 'lisp/net/eww.el'
--- a/lisp/net/eww.el   2013-06-25 19:50:05 +0000
+++ b/lisp/net/eww.el   2013-06-25 22:24:43 +0000
@@ -118,6 +118,7 @@
     (unless (string-match-p "\\'file:" url)
       (setq url (concat eww-search-prefix
                         (replace-regexp-in-string " " "+" url)))))
+  (setq eww-history-position 0)
   (url-retrieve url 'eww-render (list url)))
 
 ;;;###autoload
@@ -309,10 +310,11 @@
 
 (defun eww-setup-buffer ()
   (pop-to-buffer (get-buffer-create "*eww*"))
-  (remove-overlays)
   (let ((inhibit-read-only t))
+    (remove-overlays)
     (erase-buffer))
-  (eww-mode))
+  (unless (eq major-mode 'eww-mode)
+    (eww-mode)))
 
 (defvar eww-mode-map
   (let ((map (make-sparse-keymap)))
@@ -342,18 +344,16 @@
   (set (make-local-variable 'eww-current-url) 'author)
   (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url)
   (set (make-local-variable 'after-change-functions) 'eww-process-text-input)
+  (set (make-local-variable 'eww-history) nil)
+  (set (make-local-variable 'eww-history-position) 0)
   ;;(setq buffer-read-only t)
   )
 
 (defun eww-save-history ()
-  (let ((elem (list :url eww-current-url
-                   :point (point)
-                   :text (buffer-string))))
-    (if (or (zerop eww-history-position)
-           (= eww-history-position (length eww-history)))
-       (push elem eww-history)
-      (setcdr (nthcdr eww-history-position eww-history)
-             (cons elem (nthcdr eww-history-position eww-history))))))
+  (push (list :url eww-current-url
+             :point (point)
+             :text (buffer-string))
+       eww-history))
 
 (defun eww-browse-url (url &optional new-window)
   (when (and (equal major-mode 'eww-mode)
@@ -372,20 +372,17 @@
   (interactive)
   (when (>= eww-history-position (length eww-history))
     (error "No previous page"))
-  (eww-restore-history
-   (if (not (zerop eww-history-position))
-       (elt eww-history eww-history-position)
-     (eww-save-history)
-     (elt eww-history (1+ eww-history-position))))
-  (setq eww-history-position (1+ eww-history-position)))
+  (eww-save-history)
+  (setq eww-history-position (+ eww-history-position 2))
+  (eww-restore-history (elt eww-history (1- eww-history-position))))
 
 (defun eww-forward-url ()
   "Go to the next displayed page."
   (interactive)
   (when (zerop eww-history-position)
     (error "No next page"))
-  (eww-restore-history (elt eww-history (1- eww-history-position)))
-  (setq eww-history-position (1- eww-history-position)))
+  (eww-save-history)
+  (eww-restore-history (elt eww-history (1- eww-history-position))))
 
 (defun eww-restore-history (elem)
   (let ((inhibit-read-only t))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]