summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2013-06-14 11:16:26 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2013-06-14 11:16:26 +0000
commit4452891d08f49fb86098cf06636af8d4ce69ce2a (patch)
tree612808615708a74c7265b4c45000de153634de5c
parent1c7971e241c370f789bad6a727821ff36d5746b9 (diff)
lisp/gnus/eww.el (eww-submit): Get submit button logic right when hitting RET on non-submit buttons
lisp/gnus/shr.el: Remove shr-preliminary-table-render, since that can't really be used for anything in practice
-rw-r--r--lisp/gnus/ChangeLog8
-rw-r--r--lisp/gnus/eww.el73
-rw-r--r--lisp/gnus/shr.el4
3 files changed, 50 insertions, 35 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index aefb1e8c8a..4524dd7650 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-14 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * eww.el (eww-submit): Get submit button logic right when hitting RET
+ on non-submit buttons.
+
+ * shr.el: Remove shr-preliminary-table-render, since that can't really
+ be used for anything in practice.
+
2013-06-13 Albert Krewinkel <tarleb@moltkeplatz.de>
* sieve.el: Rebind q to (sieve-bury-buffer), bind Q to
diff --git a/lisp/gnus/eww.el b/lisp/gnus/eww.el
index e973f7d18d..270c3ee3ed 100644
--- a/lisp/gnus/eww.el
+++ b/lisp/gnus/eww.el
@@ -206,12 +206,12 @@
(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
@@ -226,18 +226,17 @@
: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))))
@@ -282,14 +281,12 @@
(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
@@ -298,19 +295,12 @@
(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
@@ -322,6 +312,25 @@
(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"))
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index b5e3b4246a..c93357efd2 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -115,7 +115,6 @@ cid: URL as the argument.")
(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)))
@@ -158,6 +157,7 @@ DOM should be a parse tree as generated by
(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))))
@@ -1167,7 +1167,6 @@ ones, in case fg and bg are nil."
(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.
@@ -1189,7 +1188,6 @@ ones, in case fg and bg are nil."
(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