[gnus git] branch master updated: m0-7-80-g1ad6846 =1= eww submit button logic
Lars Magne Ingebrigtsen <[email protected]>
| Newsgroups | gmane.emacs.gnus.cvs |
|---|---|
| Message-ID | <[email protected]> |
via 1ad6846b15e0cc71b89f2dc4851fedfe7222368c (commit)
from 50d3ec622a15a564b75611e288f77022a8d62313 (commit)
- Log -----------------------------------------------------------------
commit 1ad6846b15e0cc71b89f2dc4851fedfe7222368c
Author: Lars Magne Ingebrigtsen <[email protected]>
Date: Fri Jun 14 12:58:57 2013 +0200
eww submit button logic
* 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.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 36c6cf7..609beef 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2013-06-14 Lars Magne Ingebrigtsen <[email protected]>
+
+ * 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 <[email protected]>
* sieve.el: Rebind q to (sieve-bury-buffer), bind Q to
diff --git a/lisp/eww.el b/lisp/eww.el
index e973f7d..270c3ee 100644
--- a/lisp/eww.el
+++ b/lisp/eww.el
@@ -206,10 +206,10 @@
(widget
(cond
((equal type "submit")
- (list
- 'push-button
+ (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")
@@ -226,8 +226,7 @@
:name (cdr (assq :name cont))
:value (cdr (assq :value cont))))
(t
- (list
- 'editable-field
+ (list 'editable-field
:size (string-to-number
(or (cdr (assq :size cont))
"40"))
@@ -236,8 +235,8 @@
:action 'eww-submit
:name (cdr (assq :name cont))
:eww-form eww-form)))))
- (if (eq (car widget) 'hidden)
(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)
+ ;; 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))
- (and (not (eq (car widget) 'push-button))
- (eq (car field) 'push-button)
- first-button))
- (setq first-button nil)
(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/shr.el b/lisp/shr.el
index b5e3b42..c93357e 100644
--- a/lisp/shr.el
+++ b/lisp/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
-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.
Summary of changes:
lisp/ChangeLog | 8 ++++++
lisp/eww.el | 73 +++++++++++++++++++++++++++++++------------------------
lisp/shr.el | 4 +--
3 files changed, 50 insertions(+), 35 deletions(-)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".
The branch, master has been updated
hooks/post-receive
--
Gnus Project