From: Lars Magne Ingebrigtsen Date: Wed, 12 Jun 2013 01:38:23 +0000 (+0000) Subject: lisp/gnus/eww.el (eww-convert-widgets): Make widgets from non-tabular layouts work... X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2016^2~145^2~12 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ddf23f075fefaa77a0246ac8153fb8e89c0dbfa;p=emacs.git lisp/gnus/eww.el (eww-convert-widgets): Make widgets from non-tabular layouts work, too (eww-tag-select): Implement . + 2013-06-10 Albert Krewinkel * 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))