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: Mon, 17 Jun 2013 20:19:05 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>>>>> "Lars" == Lars Magne Ingebrigtsen <address@hidden> 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)




reply via email to

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