[gnus git] branch master updated: m0-7-50-g3534fb6 =1= Add form support.

Lars Magne Ingebrigtsen <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  3534fb65e0efc34efc8f0e8f34ef007012786602 (commit)
      from  c280d483026ebb0b8df0cb6aeb7d750ae7f888d1 (commit)


- Log -----------------------------------------------------------------
commit 3534fb65e0efc34efc8f0e8f34ef007012786602
Author: Lars Magne Ingebrigtsen <[email protected]>
Date:   Mon Jun 10 14:11:46 2013 +0200

    Add form support.
    
    * eww.el: Don't require cl-lib.
    (eww-tag-form): Start form support.
    
    * shr.el (shr-descend): Allow other packages to override (or provide)
    rendering of elements.

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9d4eab8..3bb93f7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,10 @@
 2013-06-10  Lars Magne Ingebrigtsen  <[email protected]>
 
+	* shr.el (shr-descend): Allow other packages to override (or provide)
+	rendering of elements.
+
 	* eww.el: Don't require cl-lib.
+	(eww-tag-form): Start form support.
 
 	* dgnushack.el (dgnushack-compile): Ignore eww on XEmacs.
 
diff --git a/lisp/eww.el b/lisp/eww.el
index c4a6640..badf2a0 100644
--- a/lisp/eww.el
+++ b/lisp/eww.el
@@ -82,8 +82,13 @@
 	  (libxml-parse-html-region (point) (point-max)))))
     (eww-setup-buffer)
     (setq eww-current-url url)
-    (let ((inhibit-read-only t))
-      (shr-insert-document document))
+    (let ((inhibit-read-only t)
+	  (shr-external-rendering-functions
+	   '((form . eww-tag-form)
+	     (input . eww-tag-input)
+	     (submit . eww-tag-submit))))
+      (shr-insert-document document)
+      (eww-convert-widgets))
     (goto-char (point-min))))
 
 (defun eww-display-raw (charset)
@@ -102,6 +107,8 @@
 
 (defun eww-setup-buffer ()
   (pop-to-buffer (get-buffer-create "*eww*"))
+  (remove-overlays)
+  (setq widget-field-list nil)
   (let ((inhibit-read-only t))
     (erase-buffer))
   (eww-mode))
@@ -150,6 +157,48 @@
   (let ((prev (pop eww-history)))
     (url-retrieve (car prev) 'eww-render (list (car prev) (cadr prev)))))
 
+;; Form support.
+
+(defvar eww-form nil)
+
+(defun eww-tag-form (cont)
+  (let ((eww-form
+	 (list (assq :method cont)
+	       (assq :action cont)))
+	(start (point)))
+    (shr-ensure-paragraph)
+    (shr-generic cont)
+    (shr-ensure-paragraph)
+    (put-text-property start (1+ start)
+		       'eww-form eww-form)))
+
+(defun eww-tag-input (cont)
+  (push (cons (cdr (assq :name cont))
+	      (cdr (assq :value cont)))
+	eww-form)
+  (let ((start (point))
+	(widget (list
+		 'editable-field
+		 :size (string-to-number
+			(or (cdr (assq :size cont))
+			    "40"))
+		 :value (or "____" (cdr (assq :value cont)) "")
+		 :action 'eww-submit)))
+    (apply 'widget-create widget)
+    (shr-generic cont)
+    (put-text-property start (point) 'eww-widget widget)))
+
+(defun eww-convert-widgets ()
+  (let ((start (point-min))
+	widget)
+    (while (setq start (next-single-property-change start 'eww-widget))
+      (setq widget (get-text-property start 'eww-widget))
+      (goto-char start)
+      (delete-region start (next-single-property-change start 'eww-widget))
+      (apply 'widget-create widget)
+      (put-text-property start (point) 'not-read-only t))
+    (widget-setup)))
+
 (provide 'eww)
 
 ;;; eww.el ends here
diff --git a/lisp/shr.el b/lisp/shr.el
index 6e0aa26..1d6a8ca 100644
--- a/lisp/shr.el
+++ b/lisp/shr.el
@@ -114,6 +114,7 @@ cid: URL as the argument.")
 (defvar shr-stylesheet nil)
 (defvar shr-base nil)
 (defvar shr-ignore-cache nil)
+(defvar shr-external-rendering-functions nil)
 
 (defvar shr-map
   (let ((map (make-sparse-keymap)))
@@ -291,7 +292,12 @@ size, and full-buffer size."
     (nreverse result)))
 
 (defun shr-descend (dom)
-  (let ((function (intern (concat "shr-tag-" (symbol-name (car dom))) obarray))
+  (let ((function
+	 (or
+	  ;; Allow other packages to override (or provide) rendering
+	  ;; of elements.
+	  (cdr (assq (car dom) shr-external-rendering-functions))
+	  (intern (concat "shr-tag-" (symbol-name (car dom))) obarray)))
 	(style (cdr (assq :style (cdr dom))))
 	(shr-stylesheet shr-stylesheet)
 	(start (point)))

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog |    4 ++++
 lisp/eww.el    |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 lisp/shr.el    |    8 +++++++-
 3 files changed, 62 insertions(+), 3 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.