[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113171: (eww-forward-url) Allow going forward in th
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] trunk r113171: (eww-forward-url) Allow going forward in the history, too. |
Date: |
Tue, 25 Jun 2013 15:39:16 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113171
revision-id: address@hidden
parent: address@hidden
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Tue 2013-06-25 17:39:13 +0200
message:
(eww-forward-url) Allow going forward in the history, too.
This may not be the most intuitive way to implement this. Perhaps
following links should flush "forwards"...
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 14:59:13 +0000
+++ b/lisp/ChangeLog 2013-06-25 15:39:13 +0000
@@ -2,6 +2,7 @@
* net/eww.el (eww-back-url): Implement the history by stashing all
the data into a list.
+ (eww-forward-url): Allow going forward in the history, too.
2013-06-25 Stefan Monnier <address@hidden>
=== modified file 'lisp/net/eww.el'
--- a/lisp/net/eww.el 2013-06-25 14:59:13 +0000
+++ b/lisp/net/eww.el 2013-06-25 15:39:13 +0000
@@ -86,6 +86,7 @@
(defvar eww-current-title ""
"Title of current page.")
(defvar eww-history nil)
+(defvar eww-history-position 0)
(defvar eww-next-url nil)
(defvar eww-previous-url nil)
@@ -318,6 +319,7 @@
(define-key map "\177" 'scroll-down-command)
(define-key map " " 'scroll-up-command)
(define-key map "l" 'eww-back-url)
+ (define-key map "f" 'eww-forward-url)
(define-key map "n" 'eww-next-url)
(define-key map "p" 'eww-previous-url)
(define-key map "u" 'eww-up-url)
@@ -336,13 +338,20 @@
;;(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))))))
+
(defun eww-browse-url (url &optional new-window)
(when (and (equal major-mode 'eww-mode)
eww-current-url)
- (push (list :url eww-current-url
- :point (point)
- :text (buffer-string))
- eww-history))
+ (eww-save-history))
(eww url))
(defun eww-quit ()
@@ -354,14 +363,29 @@
(defun eww-back-url ()
"Go to the previously displayed page."
(interactive)
- (when (zerop (length eww-history))
+ (when (>= eww-history-position (length eww-history))
(error "No previous page"))
- (let ((prev (pop eww-history))
- (inhibit-read-only t))
+ (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)))
+
+(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)))
+
+(defun eww-restore-history (elem)
+ (let ((inhibit-read-only t))
(erase-buffer)
- (insert (plist-get prev :text))
- (goto-char (plist-get prev :point))
- (setq eww-current-url (plist-get prev :url))))
+ (insert (plist-get elem :text))
+ (goto-char (plist-get elem :point))
+ (setq eww-current-url (plist-get elem :url))))
(defun eww-next-url ()
"Go to the page marked `next'.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113171: (eww-forward-url) Allow going forward in the history, too.,
Lars Ingebrigtsen <=