* [PATCH 2/2] eww: Add header line support.
[not found] <d8e6f9ecf128d36a11d9705912d7eacb01a95c52.1371237555.git.ruediger@c-plusplus.de>
@ 2013-06-14 19:19 ` Rüdiger Sonderfeld
2013-06-16 14:22 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 2+ messages in thread
From: Rüdiger Sonderfeld @ 2013-06-14 19:19 UTC (permalink / raw)
To: ding; +Cc: larsi
* 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] eww: Add header line support.
2013-06-14 19:19 ` [PATCH 2/2] eww: Add header line support Rüdiger Sonderfeld
@ 2013-06-16 14:22 ` Lars Magne Ingebrigtsen
0 siblings, 0 replies; 2+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-06-16 14:22 UTC (permalink / raw)
To: Rüdiger Sonderfeld; +Cc: ding
Rüdiger Sonderfeld <ruediger@c-plusplus.de> writes:
> * 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.
Thanks; applied. But I removed the "EWW: " from the default header
format. :-)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-16 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <d8e6f9ecf128d36a11d9705912d7eacb01a95c52.1371237555.git.ruediger@c-plusplus.de>
2013-06-14 19:19 ` [PATCH 2/2] eww: Add header line support Rüdiger Sonderfeld
2013-06-16 14:22 ` Lars Magne Ingebrigtsen
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).