aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2013-06-12 01:38:23 +0000
committerKatsumi Yamaoka2013-06-12 01:38:23 +0000
commit9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa (patch)
tree336525a5bd5744a6049f77e2be1a4ad2659c5c51 /lisp
parentd177e21300d9ff79ac1a293e69104c6948bad361 (diff)
downloademacs-9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa.tar.gz
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 @@
12013-06-11 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * eww.el (eww-convert-widgets): Make widgets from non-tabular layouts
4 work, too.
5 (eww-tag-select): Implement <select>.
6
12013-06-10 Albert Krewinkel <krewinkel@moltkeplatz.de> 72013-06-10 Albert Krewinkel <krewinkel@moltkeplatz.de>
2 8
3 * sieve-manage.el (sieve-manage-open): work with STARTTLS: shorten 9 * 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 @@
88 (shr-external-rendering-functions 88 (shr-external-rendering-functions
89 '((form . eww-tag-form) 89 '((form . eww-tag-form)
90 (input . eww-tag-input) 90 (input . eww-tag-input)
91 (submit . eww-tag-submit)))) 91 (select . eww-tag-select))))
92 (shr-insert-document document) 92 (shr-insert-document document)
93 (eww-convert-widgets)) 93 (eww-convert-widgets))
94 (goto-char (point-min)))) 94 (goto-char (point-min))))
@@ -201,6 +201,7 @@
201 :notify 'eww-click-radio 201 :notify 'eww-click-radio
202 :name (cdr (assq :name cont)) 202 :name (cdr (assq :name cont))
203 :checkbox-value (cdr (assq :value cont)) 203 :checkbox-value (cdr (assq :value cont))
204 :checkbox-type type
204 :eww-form eww-form 205 :eww-form eww-form
205 (cdr (assq :checked cont)))) 206 (cdr (assq :checked cont))))
206 ((equal type "hidden") 207 ((equal type "hidden")
@@ -222,20 +223,43 @@
222 (when shr-final-table-render 223 (when shr-final-table-render
223 (nconc eww-form (list widget))) 224 (nconc eww-form (list widget)))
224 (apply 'widget-create widget)) 225 (apply 'widget-create widget))
225 (put-text-property start (point) 'eww-widget widget))) 226 (put-text-property start (point) 'eww-widget widget)
227 (insert " ")))
228
229(defun eww-tag-select (cont)
230 (shr-ensure-paragraph)
231 (let ((menu (list 'menu-choice
232 :name (cdr (assq :name cont))
233 :eww-form eww-form))
234 (options nil)
235 (start (point)))
236 (dolist (elem cont)
237 (when (eq (car elem) 'option)
238 (when (cdr (assq :selected (cdr elem)))
239 (nconc menu (list :value
240 (cdr (assq :value (cdr elem))))))
241 (push (list 'item
242 :value (cdr (assq :value (cdr elem)))
243 :tag (cdr (assq 'text (cdr elem))))
244 options)))
245 (nconc menu options)
246 (apply 'widget-create menu)
247 (put-text-property start (point) 'eww-widget menu)
248 (shr-ensure-paragraph)))
226 249
227(defun eww-click-radio (widget &rest ignore) 250(defun eww-click-radio (widget &rest ignore)
228 (let ((form (plist-get (cdr widget) :eww-form)) 251 (let ((form (plist-get (cdr widget) :eww-form))
229 (name (plist-get (cdr widget) :name))) 252 (name (plist-get (cdr widget) :name)))
230 (if (widget-value widget) 253 (when (equal (plist-get (cdr widget) :type) "radio")
231 ;; Switch all the other radio buttons off. 254 (if (widget-value widget)
232 (dolist (overlay (overlays-in (point-min) (point-max))) 255 ;; Switch all the other radio buttons off.
233 (let ((field (plist-get (overlay-properties overlay) 'button))) 256 (dolist (overlay (overlays-in (point-min) (point-max)))
234 (when (and (eq (plist-get (cdr field) :eww-form) form) 257 (let ((field (plist-get (overlay-properties overlay) 'button)))
235 (equal name (plist-get (cdr field) :name))) 258 (when (and (eq (plist-get (cdr field) :eww-form) form)
236 (unless (eq field widget) 259 (equal name (plist-get (cdr field) :name)))
237 (widget-value-set field nil))))) 260 (unless (eq field widget)
238 (widget-value-set widget t)) 261 (widget-value-set field nil)))))
262 (widget-value-set widget t)))
239 (eww-fix-widget-keymap))) 263 (eww-fix-widget-keymap)))
240 264
241(defun eww-submit (widget &rest ignore) 265(defun eww-submit (widget &rest ignore)
@@ -298,12 +322,17 @@
298(defun eww-convert-widgets () 322(defun eww-convert-widgets ()
299 (let ((start (point-min)) 323 (let ((start (point-min))
300 widget) 324 widget)
325 ;; Some widgets come from different buffers (rendered for tables),
326 ;; so we need to nix out the list of widgets and recreate them.
327 (setq widget-field-list nil
328 widget-field-new nil)
301 (while (setq start (next-single-property-change start 'eww-widget)) 329 (while (setq start (next-single-property-change start 'eww-widget))
302 (setq widget (get-text-property start 'eww-widget)) 330 (setq widget (get-text-property start 'eww-widget))
303 (goto-char start) 331 (goto-char start)
304 (let ((end (next-single-property-change start 'eww-widget))) 332 (let ((end (next-single-property-change start 'eww-widget)))
305 (dolist (overlay (overlays-in start end)) 333 (dolist (overlay (overlays-in start end))
306 (when (plist-get (overlay-properties overlay) 'button) 334 (when (or (plist-get (overlay-properties overlay) 'button)
335 (plist-get (overlay-properties overlay) 'field))
307 (delete-overlay overlay))) 336 (delete-overlay overlay)))
308 (delete-region start end)) 337 (delete-region start end))
309 (apply 'widget-create widget)) 338 (apply 'widget-create widget))