Gnus development mailing list
 help / color / mirror / Atom feed
From: "Rüdiger Sonderfeld" <ruediger@c-plusplus.de>
To: ding@gnus.org
Cc: larsi@gnus.org
Subject: [PATCH 2/2] eww: Add header line support.
Date: Fri, 14 Jun 2013 21:19:54 +0200	[thread overview]
Message-ID: <1596854.Z9Q4W9ZFt7@descartes> (raw)
In-Reply-To: <d8e6f9ecf128d36a11d9705912d7eacb01a95c52.1371237555.git.ruediger@c-plusplus.de>

* 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üdiger Sonderfeld <ruediger@c-plusplus.de>
---
 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)
 
+(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)
 
 ;;;###autoload
@@ -101,15 +116,31 @@ (defun eww-display-html (charset url)
 	  (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)
 	  (shr-external-rendering-functions
-	   '((form . eww-tag-form)
+	   '((title . eww-tag-title)
+             (form . eww-tag-form)
 	     (input . eww-tag-input)
 	     (select . eww-tag-select))))
       (shr-insert-document document)
       (eww-convert-widgets))
     (goto-char (point-min))))
 
+(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)
-- 
1.8.3.1




       reply	other threads:[~2013-06-14 19:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d8e6f9ecf128d36a11d9705912d7eacb01a95c52.1371237555.git.ruediger@c-plusplus.de>
2013-06-14 19:19 ` Rüdiger Sonderfeld [this message]
2013-06-16 14:22   ` 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=1596854.Z9Q4W9ZFt7@descartes \
    --to=ruediger@c-plusplus.de \
    --cc=ding@gnus.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).