From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/83322 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?R=FCdiger?= Sonderfeld Newsgroups: gmane.emacs.gnus.general Subject: [PATCH 2/2] eww: Add header line support. Date: Fri, 14 Jun 2013 21:19:54 +0200 Message-ID: <1596854.Z9Q4W9ZFt7@descartes> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1371237699 4351 80.91.229.3 (14 Jun 2013 19:21:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 14 Jun 2013 19:21:39 +0000 (UTC) Cc: larsi@gnus.org To: ding@gnus.org Original-X-From: ding-owner+M31589@lists.math.uh.edu Fri Jun 14 21:21:39 2013 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UnZZ4-0005FB-7y for ding-account@gmane.org; Fri, 14 Jun 2013 21:21:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1UnZXV-0005Hi-E0; Fri, 14 Jun 2013 14:20:01 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1UnZXU-0005HT-2O for ding@lists.math.uh.edu; Fri, 14 Jun 2013 14:20:00 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1UnZXS-0007m5-P0 for ding@lists.math.uh.edu; Fri, 14 Jun 2013 14:19:59 -0500 Original-Received: from ptmx.org ([178.63.28.110]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1UnZXR-00086n-Bt; Fri, 14 Jun 2013 21:19:57 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ptmx.org (Postfix) with ESMTP id 232F9216D4; Fri, 14 Jun 2013 21:19:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ptmx.org Original-Received: from ptmx.org ([127.0.0.1]) by localhost (ptmx.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jfBj-aw0SRvL; Fri, 14 Jun 2013 21:19:55 +0200 (CEST) Original-Received: from descartes.localnet (chello080108246092.7.14.vie.surfer.at [80.108.246.92]) by ptmx.org (Postfix) with ESMTPSA id 91B9320CE4; Fri, 14 Jun 2013 21:19:55 +0200 (CEST) User-Agent: KMail/4.10.3 (Linux/3.8.0-23-generic; KDE/4.10.3; x86_64; ; ) In-Reply-To: X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:83322 Archived-At: * lisp/eww.el (eww): New group. (eww-header-line-format): New custom variable. (eww-current-title): New variable. (eww-display-html): Update header and handle title tag. (eww-update-header-line-format): New function. (eww-tag-title): New function. Signed-off-by: R=C3=BCdiger Sonderfeld --- lisp/eww.el | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lisp/eww.el b/lisp/eww.el index 270c3ee..726a8d5 100644 --- a/lisp/eww.el +++ b/lisp/eww.el @@ -29,7 +29,22 @@ (require 'shr) (require 'url) (require 'mm-url) =20 +(defgroup eww nil + "Emacs Web Wowser" + :version "24.4" + :group 'hypermedia + :prefix "eww-") + +(defcustom eww-header-line-format "EWW: %t: %u" + "Header line format. +- %t is replaced by the title. +- %u is replaced by the URL." + :group 'eww + :type 'string) + (defvar eww-current-url nil) +(defvar eww-current-title "" + "Title of current page.") (defvar eww-history nil) =20 ;;;###autoload @@ -101,15 +116,31 @@ (defun eww-display-html (charset url) =09 (libxml-parse-html-region (point) (point-max))))) (eww-setup-buffer) (setq eww-current-url url) + (eww-update-header-line-format) (let ((inhibit-read-only t) =09 (shr-external-rendering-functions -=09 '((form . eww-tag-form) +=09 '((title . eww-tag-title) + (form . eww-tag-form) =09 (input . eww-tag-input) =09 (select . eww-tag-select)))) (shr-insert-document document) (eww-convert-widgets)) (goto-char (point-min)))) =20 +(defun eww-update-header-line-format () + (if eww-header-line-format + (setq header-line-format (format-spec eww-header-line-format + `((?u . ,eww-current-url) + (?t . ,eww-current-title= )))) + (setq header-line-format nil))) + +(defun eww-tag-title (cont) + (setq eww-current-title "") + (dolist (sub cont) + (when (eq (car sub) 'text) + (setq eww-current-title (concat eww-current-title (cdr sub))))) + (eww-update-header-line-format)) + (defun eww-display-raw (charset) (let ((data (buffer-substring (point) (point-max)))) (eww-setup-buffer) --=20 1.8.3.1