[gnus git] branch master updated: m0-7-125-g39cb12a =1= Implement <link> and <a rel> prev/next (etc.) motions
Lars Magne Ingebrigtsen <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 39cb12ac94b96e035dcffe7f419eb77b5a41226f (commit)
from 91a1bc54b449c87ca0370ccce266243d1f771d65 (commit)
- Log -----------------------------------------------------------------
commit 39cb12ac94b96e035dcffe7f419eb77b5a41226f
Author: Tom Tromey <tromey@barimba>
Date: Tue Jun 18 17:13:58 2013 +0200
Implement <link> and <a rel> prev/next (etc.) motions
* eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
New defvars.
(eww-open-file): New defun.
(eww-render): Initialize new variables.
(eww-display-html): Handle "link" and "a".
(eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
(eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
(eww-back-url): Rename from eww-previous-url.
(eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New
defuns.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8f25af7..0e6e21c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
+2013-06-18 Tom Tromey <tromey@barimba>
+
+ * eww.el (eww-next-url, eww-previous-url, eww-up-url, eww-top-url):
+ New defvars.
+ (eww-open-file): New defun.
+ (eww-render): Initialize new variables.
+ (eww-display-html): Handle "link" and "a".
+ (eww-handle-link, eww-tag-link, eww-tag-a): New defuns.
+ (eww-mode-map): Move "p" to "l". Bind "p", "n", "t", and "u".
+ (eww-back-url): Rename from eww-previous-url.
+ (eww-next-url, eww-previous-url, eww-up-url, eww-top-url): New
+ defuns.
+
2013-06-18 Lars Magne Ingebrigtsen <[email protected]>
* shr.el (shr-tag-table): Insert the images after the table, so that
diff --git a/lisp/eww.el b/lisp/eww.el
index 3914f06..66180d9 100644
--- a/lisp/eww.el
+++ b/lisp/eww.el
@@ -56,6 +56,11 @@
"Title of current page.")
(defvar eww-history nil)
+(defvar eww-next-url nil)
+(defvar eww-previous-url nil)
+(defvar eww-up-url nil)
+(defvar eww-top-url nil)
+
;;;###autoload
(defun eww (url)
"Fetch URL and render the page."
@@ -64,10 +69,20 @@
(setq url (concat "http://" url)))
(url-retrieve url 'eww-render (list url)))
+;;;###autoload
+(defun eww-open-file (file)
+ "Render a file using EWW."
+ (interactive "fFile: ")
+ (eww (concat "file://" (expand-file-name file))))
+
(defun eww-render (status url &optional point)
(let ((redirect (plist-get status :redirect)))
(when redirect
(setq url redirect)))
+ (set (make-local-variable 'eww-next-url) nil)
+ (set (make-local-variable 'eww-previous-url) nil)
+ (set (make-local-variable 'eww-up-url) nil)
+ (set (make-local-variable 'eww-top-url) nil)
(let* ((headers (eww-parse-headers))
(shr-target-id
(and (string-match "#\\(.*\\)" url)
@@ -146,11 +161,33 @@
(input . eww-tag-input)
(textarea . eww-tag-textarea)
(body . eww-tag-body)
- (select . eww-tag-select))))
+ (select . eww-tag-select)
+ (link . eww-tag-link)
+ (a . eww-tag-a))))
(shr-insert-document document)
(eww-convert-widgets))
(goto-char (point-min))))
+(defun eww-handle-link (cont)
+ (let* ((rel (assq :rel cont))
+ (href (assq :href cont))
+ (where (assoc (cdr rel)
+ '(("next" . eww-next-url)
+ ("previous" . eww-previous-url)
+ ("start" . eww-top-url)
+ ("up" . eww-up-url)))))
+ (and href
+ where
+ (set (cdr where) (cdr href)))))
+
+(defun eww-tag-link (cont)
+ (eww-handle-link cont)
+ (shr-generic cont))
+
+(defun eww-tag-a (cont)
+ (eww-handle-link cont)
+ (shr-tag-a cont))
+
(defun eww-update-header-line-format ()
(if eww-header-line-format
(setq header-line-format (format-spec eww-header-line-format
@@ -218,8 +255,11 @@
(define-key map [delete] 'scroll-down-command)
(define-key map "\177" 'scroll-down-command)
(define-key map " " 'scroll-up-command)
+ (define-key map "l" 'eww-back-url)
+ (define-key map "n" 'eww-next-url)
(define-key map "p" 'eww-previous-url)
- ;;(define-key map "n" 'eww-next-url)
+ (define-key map "u" 'eww-up-url)
+ (define-key map "t" 'eww-top-url)
map))
(define-derived-mode eww-mode nil "eww"
@@ -240,7 +280,7 @@
(setq eww-history nil)
(kill-buffer (current-buffer)))
-(defun eww-previous-url ()
+(defun eww-back-url ()
"Go to the previously displayed page."
(interactive)
(when (zerop (length eww-history))
@@ -248,6 +288,42 @@
(let ((prev (pop eww-history)))
(url-retrieve (car prev) 'eww-render (list (car prev) (cadr prev)))))
+(defun eww-next-url ()
+ "Go to the page marked `next'.
+A page is marked `next' if rel=\"next\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-next-url
+ (eww-browse-url (shr-expand-url eww-next-url eww-current-url))
+ (error "No `next' on this page")))
+
+(defun eww-previous-url ()
+ "Go to the page marked `previous'.
+A page is marked `previous' if rel=\"previous\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-previous-url
+ (eww-browse-url (shr-expand-url eww-previous-url eww-current-url))
+ (error "No `previous' on this page")))
+
+(defun eww-up-url ()
+ "Go to the page marked `up'.
+A page is marked `up' if rel=\"up\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-up-url
+ (eww-browse-url (shr-expand-url eww-up-url eww-current-url))
+ (error "No `up' on this page")))
+
+(defun eww-top-url ()
+ "Go to the page marked `top'.
+A page is marked `top' if rel=\"start\" appears in a <link>
+or <a> tag."
+ (interactive)
+ (if eww-top-url
+ (eww-browse-url (shr-expand-url eww-top-url eww-current-url))
+ (error "No `top' on this page")))
+
(defun eww-reload ()
"Reload the current page."
(interactive)
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 13 +++++++++
lisp/eww.el | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 92 insertions(+), 3 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project