(widget
(cond
((equal type "submit")
- (list
- 'push-button
- :notify 'eww-submit
- :name (cdr (assq :name cont))
- :eww-form eww-form
- (or (cdr (assq :value cont)) "Submit")))
+ (list 'push-button
+ :notify 'eww-submit
+ :name (cdr (assq :name cont))
+ :value (cdr (assq :value cont))
+ :eww-form eww-form
+ (or (cdr (assq :value cont)) "Submit")))
((or (equal type "radio")
(equal type "checkbox"))
(list 'checkbox
:name (cdr (assq :name cont))
:value (cdr (assq :value cont))))
(t
- (list
- 'editable-field
- :size (string-to-number
- (or (cdr (assq :size cont))
- "40"))
- :value (or (cdr (assq :value cont)) "")
- :secret (and (equal type "password") ?*)
- :action 'eww-submit
- :name (cdr (assq :name cont))
- :eww-form eww-form)))))
- (if (eq (car widget) 'hidden)
- (nconc eww-form (list widget))
+ (list 'editable-field
+ :size (string-to-number
+ (or (cdr (assq :size cont))
+ "40"))
+ :value (or (cdr (assq :value cont)) "")
+ :secret (and (equal type "password") ?*)
+ :action 'eww-submit
+ :name (cdr (assq :name cont))
+ :eww-form eww-form)))))
+ (nconc eww-form (list widget))
+ (unless (eq (car widget) 'hidden)
(apply 'widget-create widget)
(put-text-property start (point) 'eww-widget widget))))
(defun eww-submit (widget &rest ignore)
(let ((form (plist-get (cdr widget) :eww-form))
- (first-button t)
values)
(dolist (overlay (sort (overlays-in (point-min) (point-max))
(lambda (o1 o2)
(< (overlay-start o1) (overlay-start o2)))))
(let ((field (or (plist-get (overlay-properties overlay) 'field)
- (plist-get (overlay-properties overlay) 'button)
- (plist-get (overlay-properties overlay) 'eww-hidden))))
+ (plist-get (overlay-properties overlay) 'button))))
(when (eq (plist-get (cdr field) :eww-form) form)
(let ((name (plist-get (cdr field) :name)))
(when name
(when (widget-value field)
(push (cons name (plist-get (cdr field) :checkbox-value))
values)))
- ((eq (car field) 'eww-hidden)
- (push (cons name (plist-get (cdr field) :value))
- values))
((eq (car field) 'push-button)
;; We want the values from buttons if we hit a button,
- ;; or we're submitting something and this is the first
- ;; button displayed.
- (when (or (and (eq (car widget) 'push-button)
- (eq widget field))
- (and (not (eq (car widget) 'push-button))
- (eq (car field) 'push-button)
- first-button))
- (setq first-button nil)
+ ;; if it's the first button in the DOM after the field
+ ;; hit ENTER on.
+ (when (and (eq (car widget) 'push-button)
+ (eq widget field))
(push (cons name (widget-value field))
values)))
(t
(push (cons (plist-get (cdr elem) :name)
(plist-get (cdr elem) :value))
values)))
+ ;; If we hit ENTER in a non-button field, include the value of the
+ ;; first submit button after it.
+ (unless (eq (car widget) 'push-button)
+ (let ((rest form)
+ (name (plist-get (cdr widget) :name)))
+ (when rest
+ (while (and rest
+ (or (not (consp (car rest)))
+ (not (equal name (plist-get (cdar rest) :name)))))
+ (pop rest)))
+ (while rest
+ (let ((elem (pop rest)))
+ (when (and (consp (car rest))
+ (eq (car elem) 'push-button))
+ (push (cons (plist-get (cdr elem) :name)
+ (plist-get (cdr elem) :value))
+ values)
+ (setq rest nil))))))
+ (debug values)
(let ((shr-base eww-current-url))
(if (and (stringp (cdr (assq :method form)))
(equal (downcase (cdr (assq :method form))) "post"))
(defvar shr-base nil)
(defvar shr-ignore-cache nil)
(defvar shr-external-rendering-functions nil)
-(defvar shr-preliminary-table-render nil)
(defvar shr-map
(let ((map (make-sparse-keymap)))
(shr-state nil)
(shr-start nil)
(shr-base nil)
+ (shr-preliminary-table-render 0)
(shr-width (or shr-width (window-width))))
(shr-descend (shr-transform-dom dom))
(shr-remove-trailing-whitespace start (point))))
(setq cont (or (cdr (assq 'tbody cont))
cont))
(let* ((shr-inhibit-images t)
- (shr-preliminary-table-render t)
(shr-table-depth (1+ shr-table-depth))
(shr-kinsoku-shorten t)
;; Find all suggested widths.
(frame-width))
(setq truncate-lines t))
;; Then render the table again with these new "hard" widths.
- (setq shr-preliminary-table-render nil)
(shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths))
;; Finally, insert all the images after the table. The Emacs buffer
;; model isn't strong enough to allow us to put the images actually