From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: eww Date: Mon, 17 Jun 2013 20:19:05 -0600 Message-ID: <87d2rkb1pi.fsf@fleche.redhat.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371521964 21192 80.91.229.3 (18 Jun 2013 02:19:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Jun 2013 02:19:24 +0000 (UTC) Cc: ding@gnus.org, emacs-devel To: Lars Magne Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 18 04:19:23 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UolVz-0000m1-3H for ged-emacs-devel@m.gmane.org; Tue, 18 Jun 2013 04:19:23 +0200 Original-Received: from localhost ([::1]:42530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UolVy-0003FO-IF for ged-emacs-devel@m.gmane.org; Mon, 17 Jun 2013 22:19:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UolVr-0003F7-FV for emacs-devel@gnu.org; Mon, 17 Jun 2013 22:19:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UolVm-0007EV-U1 for emacs-devel@gnu.org; Mon, 17 Jun 2013 22:19:15 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:6848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UolVm-0007DV-M5 for emacs-devel@gnu.org; Mon, 17 Jun 2013 22:19:10 -0400 Original-Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5I2J8Gq026983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 17 Jun 2013 22:19:08 -0400 Original-Received: from barimba (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5I2J6xJ028232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 17 Jun 2013 22:19:06 -0400 X-Attribution: Tom In-Reply-To: (Lars Magne Ingebrigtsen's message of "Sun, 16 Jun 2013 16:53:57 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160546 gmane.emacs.gnus.general:83355 Archived-At: >>>>> "Lars" == Lars Magne Ingebrigtsen 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 and 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)