summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2013-06-12 01:38:23 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2013-06-12 01:38:23 +0000
commit9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa (patch)
tree336525a5bd5744a6049f77e2be1a4ad2659c5c51 /lisp
parentd177e21300d9ff79ac1a293e69104c6948bad361 (diff)
downloademacs-9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa.tar.gz
emacs-9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa.tar.bz2
emacs-9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa.zip
lisp/gnus/eww.el (eww-convert-widgets): Make widgets from non-tabular layouts work, too
(eww-tag-select): Implement <select>
Diffstat (limited to 'lisp')
-rw-r--r--lisp/gnus/ChangeLog6
-rw-r--r--lisp/gnus/eww.el53
2 files changed, 47 insertions, 12 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 744e1871b65..ac5cdfafca2 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,9 @@
+2013-06-11 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * eww.el (eww-convert-widgets): Make widgets from non-tabular layouts
+ work, too.
+ (eww-tag-select): Implement <select>.
+
2013-06-10 Albert Krewinkel <krewinkel@moltkeplatz.de>
* sieve-manage.el (sieve-manage-open): work with STARTTLS: shorten
diff --git a/lisp/gnus/eww.el b/lisp/gnus/eww.el
index ca7b8c097be..3e799732ecb 100644
--- a/lisp/gnus/eww.el
+++ b/lisp/gnus/eww.el
@@ -88,7 +88,7 @@
(shr-external-rendering-functions
'((form . eww-tag-form)
(input . eww-tag-input)
- (submit . eww-tag-submit))))
+ (select . eww-tag-select))))
(shr-insert-document document)
(eww-convert-widgets))
(goto-char (point-min))))
@@ -201,6 +201,7 @@
:notify 'eww-click-radio
:name (cdr (assq :name cont))
:checkbox-value (cdr (assq :value cont))
+ :checkbox-type type
:eww-form eww-form
(cdr (assq :checked cont))))
((equal type "hidden")
@@ -222,20 +223,43 @@
(when shr-final-table-render
(nconc eww-form (list widget)))
(apply 'widget-create widget))
- (put-text-property start (point) 'eww-widget widget)))
+ (put-text-property start (point) 'eww-widget widget)
+ (insert " ")))
+
+(defun eww-tag-select (cont)
+ (shr-ensure-paragraph)
+ (let ((menu (list 'menu-choice
+ :name (cdr (assq :name cont))
+ :eww-form eww-form))
+ (options nil)
+ (start (point)))
+ (dolist (elem cont)
+ (when (eq (car elem) 'option)
+ (when (cdr (assq :selected (cdr elem)))
+ (nconc menu (list :value
+ (cdr (assq :value (cdr elem))))))
+ (push (list 'item
+ :value (cdr (assq :value (cdr elem)))
+ :tag (cdr (assq 'text (cdr elem))))
+ options)))
+ (nconc menu options)
+ (apply 'widget-create menu)
+ (put-text-property start (point) 'eww-widget menu)
+ (shr-ensure-paragraph)))
(defun eww-click-radio (widget &rest ignore)
(let ((form (plist-get (cdr widget) :eww-form))
(name (plist-get (cdr widget) :name)))
- (if (widget-value widget)
- ;; Switch all the other radio buttons off.
- (dolist (overlay (overlays-in (point-min) (point-max)))
- (let ((field (plist-get (overlay-properties overlay) 'button)))
- (when (and (eq (plist-get (cdr field) :eww-form) form)
- (equal name (plist-get (cdr field) :name)))
- (unless (eq field widget)
- (widget-value-set field nil)))))
- (widget-value-set widget t))
+ (when (equal (plist-get (cdr widget) :type) "radio")
+ (if (widget-value widget)
+ ;; Switch all the other radio buttons off.
+ (dolist (overlay (overlays-in (point-min) (point-max)))
+ (let ((field (plist-get (overlay-properties overlay) 'button)))
+ (when (and (eq (plist-get (cdr field) :eww-form) form)
+ (equal name (plist-get (cdr field) :name)))
+ (unless (eq field widget)
+ (widget-value-set field nil)))))
+ (widget-value-set widget t)))
(eww-fix-widget-keymap)))
(defun eww-submit (widget &rest ignore)
@@ -298,12 +322,17 @@
(defun eww-convert-widgets ()
(let ((start (point-min))
widget)
+ ;; Some widgets come from different buffers (rendered for tables),
+ ;; so we need to nix out the list of widgets and recreate them.
+ (setq widget-field-list nil
+ widget-field-new nil)
(while (setq start (next-single-property-change start 'eww-widget))
(setq widget (get-text-property start 'eww-widget))
(goto-char start)
(let ((end (next-single-property-change start 'eww-widget)))
(dolist (overlay (overlays-in start end))
- (when (plist-get (overlay-properties overlay) 'button)
+ (when (or (plist-get (overlay-properties overlay) 'button)
+ (plist-get (overlay-properties overlay) 'field))
(delete-overlay overlay)))
(delete-region start end))
(apply 'widget-create widget))