diff options
| author | Lars Magne Ingebrigtsen | 2013-06-26 00:24:43 +0200 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2013-06-26 00:24:43 +0200 |
| commit | 8308f184984d5c10fee62990d8a01abcec7f2160 (patch) | |
| tree | 5d635cdbd83496d71f0a53b418786a045472aed5 /lisp | |
| parent | e080a9d7307025e73c9682c201e60206f7b4e808 (diff) | |
| download | emacs-8308f184984d5c10fee62990d8a01abcec7f2160.tar.gz emacs-8308f184984d5c10fee62990d8a01abcec7f2160.zip | |
* net/eww.el: Rework history traversal.
When going forward/back, put these actions into the history, too, so
that they can be replayed.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/eww.el | 33 |
2 files changed, 21 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d65ffc0cf5c..10b5daaac04 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-06-25 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * net/eww.el: Rework history traversal. When going forward/back, | ||
| 4 | put these actions into the history, too, so that they can be | ||
| 5 | replayed. | ||
| 6 | |||
| 1 | 2013-06-25 Juri Linkov <juri@jurta.org> | 7 | 2013-06-25 Juri Linkov <juri@jurta.org> |
| 2 | 8 | ||
| 3 | * files-x.el (modify-dir-local-variable): Change the header comment | 9 | * files-x.el (modify-dir-local-variable): Change the header comment |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 2d6fe9a08dc..eaff1a1b985 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -118,6 +118,7 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 118 | (unless (string-match-p "\\'file:" url) | 118 | (unless (string-match-p "\\'file:" url) |
| 119 | (setq url (concat eww-search-prefix | 119 | (setq url (concat eww-search-prefix |
| 120 | (replace-regexp-in-string " " "+" url))))) | 120 | (replace-regexp-in-string " " "+" url))))) |
| 121 | (setq eww-history-position 0) | ||
| 121 | (url-retrieve url 'eww-render (list url))) | 122 | (url-retrieve url 'eww-render (list url))) |
| 122 | 123 | ||
| 123 | ;;;###autoload | 124 | ;;;###autoload |
| @@ -309,10 +310,11 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 309 | 310 | ||
| 310 | (defun eww-setup-buffer () | 311 | (defun eww-setup-buffer () |
| 311 | (pop-to-buffer (get-buffer-create "*eww*")) | 312 | (pop-to-buffer (get-buffer-create "*eww*")) |
| 312 | (remove-overlays) | ||
| 313 | (let ((inhibit-read-only t)) | 313 | (let ((inhibit-read-only t)) |
| 314 | (remove-overlays) | ||
| 314 | (erase-buffer)) | 315 | (erase-buffer)) |
| 315 | (eww-mode)) | 316 | (unless (eq major-mode 'eww-mode) |
| 317 | (eww-mode))) | ||
| 316 | 318 | ||
| 317 | (defvar eww-mode-map | 319 | (defvar eww-mode-map |
| 318 | (let ((map (make-sparse-keymap))) | 320 | (let ((map (make-sparse-keymap))) |
| @@ -342,18 +344,16 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 342 | (set (make-local-variable 'eww-current-url) 'author) | 344 | (set (make-local-variable 'eww-current-url) 'author) |
| 343 | (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url) | 345 | (set (make-local-variable 'browse-url-browser-function) 'eww-browse-url) |
| 344 | (set (make-local-variable 'after-change-functions) 'eww-process-text-input) | 346 | (set (make-local-variable 'after-change-functions) 'eww-process-text-input) |
| 347 | (set (make-local-variable 'eww-history) nil) | ||
| 348 | (set (make-local-variable 'eww-history-position) 0) | ||
| 345 | ;;(setq buffer-read-only t) | 349 | ;;(setq buffer-read-only t) |
| 346 | ) | 350 | ) |
| 347 | 351 | ||
| 348 | (defun eww-save-history () | 352 | (defun eww-save-history () |
| 349 | (let ((elem (list :url eww-current-url | 353 | (push (list :url eww-current-url |
| 350 | :point (point) | 354 | :point (point) |
| 351 | :text (buffer-string)))) | 355 | :text (buffer-string)) |
| 352 | (if (or (zerop eww-history-position) | 356 | eww-history)) |
| 353 | (= eww-history-position (length eww-history))) | ||
| 354 | (push elem eww-history) | ||
| 355 | (setcdr (nthcdr eww-history-position eww-history) | ||
| 356 | (cons elem (nthcdr eww-history-position eww-history)))))) | ||
| 357 | 357 | ||
| 358 | (defun eww-browse-url (url &optional new-window) | 358 | (defun eww-browse-url (url &optional new-window) |
| 359 | (when (and (equal major-mode 'eww-mode) | 359 | (when (and (equal major-mode 'eww-mode) |
| @@ -372,20 +372,17 @@ word(s) will be searched for via `eww-search-prefix'." | |||
| 372 | (interactive) | 372 | (interactive) |
| 373 | (when (>= eww-history-position (length eww-history)) | 373 | (when (>= eww-history-position (length eww-history)) |
| 374 | (error "No previous page")) | 374 | (error "No previous page")) |
| 375 | (eww-restore-history | 375 | (eww-save-history) |
| 376 | (if (not (zerop eww-history-position)) | 376 | (setq eww-history-position (+ eww-history-position 2)) |
| 377 | (elt eww-history eww-history-position) | 377 | (eww-restore-history (elt eww-history (1- eww-history-position)))) |
| 378 | (eww-save-history) | ||
| 379 | (elt eww-history (1+ eww-history-position)))) | ||
| 380 | (setq eww-history-position (1+ eww-history-position))) | ||
| 381 | 378 | ||
| 382 | (defun eww-forward-url () | 379 | (defun eww-forward-url () |
| 383 | "Go to the next displayed page." | 380 | "Go to the next displayed page." |
| 384 | (interactive) | 381 | (interactive) |
| 385 | (when (zerop eww-history-position) | 382 | (when (zerop eww-history-position) |
| 386 | (error "No next page")) | 383 | (error "No next page")) |
| 387 | (eww-restore-history (elt eww-history (1- eww-history-position))) | 384 | (eww-save-history) |
| 388 | (setq eww-history-position (1- eww-history-position))) | 385 | (eww-restore-history (elt eww-history (1- eww-history-position)))) |
| 389 | 386 | ||
| 390 | (defun eww-restore-history (elem) | 387 | (defun eww-restore-history (elem) |
| 391 | (let ((inhibit-read-only t)) | 388 | (let ((inhibit-read-only t)) |