emacs-devel
[Top][All Lists]
Advanced

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

Re: eww


From: Tom Tromey
Subject: Re: eww
Date: Wed, 19 Jun 2013 11:13:39 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Lars> Could you re-send the patch against the current tree?

Here you go.
I can push directly if you prefer.
I think it would be best if you reviewed patches, though.

Tom

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2013-06-19 13:14:24 +0000
+++ lisp/ChangeLog      2013-06-19 17:13:17 +0000
@@ -1,3 +1,12 @@
+2013-06-19  Tom Tromey  <address@hidden>
+
+       * net/eww.el (eww-top-url): Remove.
+       (eww-home-url, eww-start-url, eww-contents-url): New defvars.
+       (eww-render): Set new variables.  Don't set eww-top-url.
+       (eww-handle-link): Handle "prev", "home", and "contents".
+       Downcase the rel text.
+       (eww-top-url): Choose best top URL.
+
 2013-06-19  Michael Albinus  <address@hidden>
 
        * net/tramp-adb.el (tramp-adb-get-toolbox): Remove function, it is

=== modified file 'lisp/net/eww.el'
--- lisp/net/eww.el     2013-06-18 22:38:34 +0000
+++ lisp/net/eww.el     2013-06-19 17:10:12 +0000
@@ -59,7 +59,9 @@
 (defvar eww-next-url nil)
 (defvar eww-previous-url nil)
 (defvar eww-up-url nil)
-(defvar eww-top-url nil)
+(defvar eww-home-url nil)
+(defvar eww-start-url nil)
+(defvar eww-contents-url nil)
 
 ;;;###autoload
 (defun eww (url)
@@ -82,7 +84,9 @@
   (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)
+  (set (make-local-variable 'eww-home-url) nil)
+  (set (make-local-variable 'eww-start-url) nil)
+  (set (make-local-variable 'eww-contents-url) nil)
   (let* ((headers (eww-parse-headers))
         (shr-target-id
          (and (string-match "#\\(.*\\)" url)
@@ -171,10 +175,22 @@
 (defun eww-handle-link (cont)
   (let* ((rel (assq :rel cont))
        (href (assq :href cont))
-       (where (assoc (cdr rel)
+       (where (assoc
+               ;; The text associated with :rel is case-insensitive.
+               (if rel (downcase (cdr rel)))
                      '(("next" . eww-next-url)
+                       ;; Texinfo uses "previous", but HTML specifies
+                       ;; "prev", so recognize both.
                        ("previous" . eww-previous-url)
-                       ("start" . eww-top-url)
+                       ("prev" . eww-previous-url)
+                       ;; 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)))))
     (and href
         where
@@ -317,12 +333,15 @@
 
 (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."
+A page is marked `top' if rel=\"start\", rel=\"home\", or rel=\"contents\"
+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")))
+  (let ((best-url (or eww-start-url
+                     eww-contents-url
+                     eww-home-url)))
+    (if best-url
+       (eww-browse-url (shr-expand-url best-url eww-current-url))
+      (error "No `top' for this page"))))
 
 (defun eww-reload ()
   "Reload the current page."




reply via email to

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