Gnus development mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: ding@gnus.org, emacs-devel <emacs-devel@gnu.org>
Subject: Re: eww
Date: Mon, 17 Jun 2013 20:19:05 -0600	[thread overview]
Message-ID: <87d2rkb1pi.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m31u82jed6.fsf@stories.gnus.org> (Lars Magne Ingebrigtsen's message of "Sun, 16 Jun 2013 16:53:57 +0200")

>>>>> "Lars" == Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

Lars> eww probably has a lot of stuff that could still be fixed up, but
Lars> the basics are working now.  That is, you can search for stuff on
Lars> Google and visit Wikipedia.  :-)

Very nice.

I played with it a bit.

It doesn't render parts of the gdb manual very nicely.
For example in the reverse execution node, the info looks like:

================================================================
   If you are debugging in a target environment that supports reverse
execution, GDB provides the following commands.

`reverse-continue [IGNORE-COUNT]'
`rc [IGNORE-COUNT]'
     Beginning at the point where your program last stopped, start
     executing in reverse.  Reverse execution will stop for breakpoints
     and synchronous exceptions (signals), just like normal execution.
     Behavior of asynchronous signals depends on the target environment.
================================================================

but eww renders it as

================================================================
If you are debugging in a target environment that supports reverse execution,
gdb provides the following commands.

reverse-continue [ignore-count]rc [ignore-count]Beginning at the point where
your program last stopped, start executing in reverse. Reverse execution will
stop for breakpoints and synchronous exceptions (signals), just like normal
execution. Behavior of asynchronous signals depends on the target environment.
================================================================


Also, please consider the appended patch.  It makes eww pick up on
<link> and <a rel=...> to give it a more info-ish flavor.  I'm
interested in the possibility of replacing info with html+eww.

The patch isn't perfect but I thought I'd see what you think before
going any further.

Tom

=== modified file 'lisp/gnus/eww.el'
--- lisp/gnus/eww.el	2013-06-17 23:11:40 +0000
+++ lisp/gnus/eww.el	2013-06-18 02:06:16 +0000
@@ -56,6 +56,15 @@
   "Title of current page.")
 (defvar eww-history nil)
 
+(defvar eww-next-url nil)
+(make-variable-buffer-local 'eww-next-url)
+(defvar eww-previous-url nil)
+(make-variable-buffer-local 'eww-previous-url)
+(defvar eww-up-url nil)
+(make-variable-buffer-local 'eww-up-url)
+(defvar eww-top-url nil)
+(make-variable-buffer-local 'eww-top-url)
+
 ;;;###autoload
 (defun eww (url)
   "Fetch URL and render the page."
@@ -64,6 +73,12 @@
     (setq url (concat "http://" url)))
   (url-retrieve url 'eww-render (list url)))
 
+;;;###autoload
+(defun eww-open-file (file)
+  (interactive "fFile: ")
+  (let ((browse-url-browser-function #'eww-browse-url))
+    (browse-url-of-file (expand-file-name file))))
+
 (defun eww-detect-charset (html-p)
   (let ((case-fold-search t)
 	(pt (point)))
@@ -80,6 +95,10 @@
   (let ((redirect (plist-get status :redirect)))
     (when redirect
       (setq url redirect)))
+  (setq eww-next-url nil)
+  (setq eww-previous-url nil)
+  (setq eww-up-url nil)
+  (setq eww-top-url nil)
   (let* ((headers (eww-parse-headers))
 	 (shr-target-id
 	  (and (string-match "#\\(.*\\)" url)
@@ -146,10 +165,32 @@
 	     (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))))
+      (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
@@ -218,8 +259,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 +284,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 +292,30 @@
   (let ((prev (pop eww-history)))
     (url-retrieve (car prev) 'eww-render (list (car prev) (cadr prev)))))
 
+(defun eww-next-url ()
+  (interactive)
+  (if eww-next-url
+      (eww-browse-url (shr-expand-url eww-next-url eww-current-url))
+    (error "No `next' on this node")))
+
+(defun eww-previous-url ()
+  (interactive)
+  (if eww-previous-url
+      (eww-browse-url (shr-expand-url eww-previous-url eww-current-url))
+    (error "No `previous' on this node")))
+
+(defun eww-up-url ()
+  (interactive)
+  (if eww-up-url
+      (eww-browse-url (shr-expand-url eww-up-url eww-current-url))
+    (error "No `up' on this node")))
+
+(defun eww-top-url ()
+  (interactive)
+  (if eww-top-url
+      (eww-browse-url (shr-expand-url eww-top-url eww-current-url))
+    (error "No `top' on this node")))
+
 (defun eww-reload ()
   "Reload the current page."
   (interactive)




  parent reply	other threads:[~2013-06-18  2:19 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16 14:53 eww Lars Magne Ingebrigtsen
2013-06-16 15:21 ` eww Adam Sjøgren
2013-06-16 15:29   ` eww Lars Magne Ingebrigtsen
2013-06-16 15:46     ` eww Lars Magne Ingebrigtsen
2013-06-16 17:01       ` eww Dmitry Gutov
2013-06-16 17:06         ` eww Lars Magne Ingebrigtsen
2013-06-17 21:00           ` eww Lars Magne Ingebrigtsen
2013-06-17 23:35             ` eww Ted Zlatanov
2013-06-18  0:01               ` eww Lars Magne Ingebrigtsen
2013-07-09 13:20                 ` eww Ted Zlatanov
2013-08-01 14:39                   ` eww Lars Magne Ingebrigtsen
2013-07-09 10:23               ` eww Julien Cubizolles
2013-07-09 10:42                 ` eww David Edmondson
2013-06-16 23:42 ` eww lee
2013-06-17  5:57   ` eww Lars Magne Ingebrigtsen
2013-06-17 18:46     ` eww lee
2013-06-18  2:19 ` Tom Tromey [this message]
2013-06-18 11:23   ` eww Lars Magne Ingebrigtsen
2013-06-18 14:34     ` eww Tom Tromey
2013-06-18 15:01       ` eww Lars Magne Ingebrigtsen
2013-06-18 15:43         ` eww Tom Tromey
2013-06-18 14:39     ` eww Tom Tromey
2013-06-18 15:14       ` eww Lars Magne Ingebrigtsen
2013-06-18 16:17         ` eww Tom Tromey
2013-06-18 19:06           ` eww Steinar Bang
2013-06-18 19:07     ` eww Stefan Monnier
2013-06-18 11:31   ` eww Lars Magne Ingebrigtsen
2013-06-18 14:42     ` eww Tom Tromey
2013-06-18 15:04       ` eww Lars Magne Ingebrigtsen
2013-06-18 19:13         ` eww Stefan Monnier
2013-06-18 19:17           ` eww Eli Zaretskii
2013-06-18 20:21             ` eww Stefan Monnier
2013-06-18 23:34               ` eww James Cloos
2013-06-19  2:50               ` eww Eli Zaretskii
2013-06-19  4:49                 ` eww Stefan Monnier
2013-06-18 23:03             ` eww Xue Fuqiao
2013-06-19  3:03               ` eww Eli Zaretskii
2013-06-18 19:27           ` eww Tom Tromey
2013-06-18 23:40     ` eww Juri Linkov
2013-06-19  0:51       ` eww Stefan Monnier
2013-06-19  1:08         ` eww Russ Allbery
2013-06-19 10:14           ` eww Rasmus
2013-06-19 10:34         ` eww Christopher Schmidt
2013-06-25  7:43       ` eww lee
2013-06-25  9:05         ` eww Tassilo Horn
2013-06-25 13:27           ` eww Steinar Bang
2013-06-27  9:05           ` eww lee
2013-06-18 11:32 ` eww joakim
2013-06-18 12:16   ` eww Andreas Schwab
2013-06-18 13:57   ` eww Lars Magne Ingebrigtsen
2013-06-18 14:01     ` eww joakim
2013-06-19 10:21 ` eww Ivan Kanis
2013-06-19 11:52   ` eww Steinar Bang
2013-06-19 12:14   ` eww Ivan Kanis
2013-08-01 11:59 ` eww John Williams
2013-08-02  0:20   ` eww John Williams
2013-08-02  0:27     ` eww Lars Magne Ingebrigtsen
2013-08-02 19:48       ` eww Richard Stallman
2013-08-03 11:30         ` eww Lars Magne Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d2rkb1pi.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=ding@gnus.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).