aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2013-06-14 11:16:26 +0000
committerKatsumi Yamaoka2013-06-14 11:16:26 +0000
commit4452891d08f49fb86098cf06636af8d4ce69ce2a (patch)
tree612808615708a74c7265b4c45000de153634de5c
parent1c7971e241c370f789bad6a727821ff36d5746b9 (diff)
downloademacs-4452891d08f49fb86098cf06636af8d4ce69ce2a.tar.gz
emacs-4452891d08f49fb86098cf06636af8d4ce69ce2a.zip
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 aefb1e8c8a3..4524dd76504 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,11 @@
12013-06-14 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * eww.el (eww-submit): Get submit button logic right when hitting RET
4 on non-submit buttons.
5
6 * shr.el: Remove shr-preliminary-table-render, since that can't really
7 be used for anything in practice.
8
12013-06-13 Albert Krewinkel <tarleb@moltkeplatz.de> 92013-06-13 Albert Krewinkel <tarleb@moltkeplatz.de>
2 10
3 * sieve.el: Rebind q to (sieve-bury-buffer), bind Q to 11 * sieve.el: Rebind q to (sieve-bury-buffer), bind Q to
diff --git a/lisp/gnus/eww.el b/lisp/gnus/eww.el
index e973f7d18d7..270c3ee3ed2 100644
--- a/lisp/gnus/eww.el
+++ b/lisp/gnus/eww.el
@@ -206,12 +206,12 @@
206 (widget 206 (widget
207 (cond 207 (cond
208 ((equal type "submit") 208 ((equal type "submit")
209 (list 209 (list 'push-button
210 'push-button 210 :notify 'eww-submit
211 :notify 'eww-submit 211 :name (cdr (assq :name cont))
212 :name (cdr (assq :name cont)) 212 :value (cdr (assq :value cont))
213 :eww-form eww-form 213 :eww-form eww-form
214 (or (cdr (assq :value cont)) "Submit"))) 214 (or (cdr (assq :value cont)) "Submit")))
215 ((or (equal type "radio") 215 ((or (equal type "radio")
216 (equal type "checkbox")) 216 (equal type "checkbox"))
217 (list 'checkbox 217 (list 'checkbox
@@ -226,18 +226,17 @@
226 :name (cdr (assq :name cont)) 226 :name (cdr (assq :name cont))
227 :value (cdr (assq :value cont)))) 227 :value (cdr (assq :value cont))))
228 (t 228 (t
229 (list 229 (list 'editable-field
230 'editable-field 230 :size (string-to-number
231 :size (string-to-number 231 (or (cdr (assq :size cont))
232 (or (cdr (assq :size cont)) 232 "40"))
233 "40")) 233 :value (or (cdr (assq :value cont)) "")
234 :value (or (cdr (assq :value cont)) "") 234 :secret (and (equal type "password") ?*)
235 :secret (and (equal type "password") ?*) 235 :action 'eww-submit
236 :action 'eww-submit 236 :name (cdr (assq :name cont))
237 :name (cdr (assq :name cont)) 237 :eww-form eww-form)))))
238 :eww-form eww-form))))) 238 (nconc eww-form (list widget))
239 (if (eq (car widget) 'hidden) 239 (unless (eq (car widget) 'hidden)
240 (nconc eww-form (list widget))
241 (apply 'widget-create widget) 240 (apply 'widget-create widget)
242 (put-text-property start (point) 'eww-widget widget)))) 241 (put-text-property start (point) 'eww-widget widget))))
243 242
@@ -282,14 +281,12 @@
282 281
283(defun eww-submit (widget &rest ignore) 282(defun eww-submit (widget &rest ignore)
284 (let ((form (plist-get (cdr widget) :eww-form)) 283 (let ((form (plist-get (cdr widget) :eww-form))
285 (first-button t)
286 values) 284 values)
287 (dolist (overlay (sort (overlays-in (point-min) (point-max)) 285 (dolist (overlay (sort (overlays-in (point-min) (point-max))
288 (lambda (o1 o2) 286 (lambda (o1 o2)
289 (< (overlay-start o1) (overlay-start o2))))) 287 (< (overlay-start o1) (overlay-start o2)))))
290 (let ((field (or (plist-get (overlay-properties overlay) 'field) 288 (let ((field (or (plist-get (overlay-properties overlay) 'field)
291 (plist-get (overlay-properties overlay) 'button) 289 (plist-get (overlay-properties overlay) 'button))))
292 (plist-get (overlay-properties overlay) 'eww-hidden))))
293 (when (eq (plist-get (cdr field) :eww-form) form) 290 (when (eq (plist-get (cdr field) :eww-form) form)
294 (let ((name (plist-get (cdr field) :name))) 291 (let ((name (plist-get (cdr field) :name)))
295 (when name 292 (when name
@@ -298,19 +295,12 @@
298 (when (widget-value field) 295 (when (widget-value field)
299 (push (cons name (plist-get (cdr field) :checkbox-value)) 296 (push (cons name (plist-get (cdr field) :checkbox-value))
300 values))) 297 values)))
301 ((eq (car field) 'eww-hidden)
302 (push (cons name (plist-get (cdr field) :value))
303 values))
304 ((eq (car field) 'push-button) 298 ((eq (car field) 'push-button)
305 ;; We want the values from buttons if we hit a button, 299 ;; We want the values from buttons if we hit a button,
306 ;; or we're submitting something and this is the first 300 ;; if it's the first button in the DOM after the field
307 ;; button displayed. 301 ;; hit ENTER on.
308 (when (or (and (eq (car widget) 'push-button) 302 (when (and (eq (car widget) 'push-button)
309 (eq widget field)) 303 (eq widget field))
310 (and (not (eq (car widget) 'push-button))
311 (eq (car field) 'push-button)
312 first-button))
313 (setq first-button nil)
314 (push (cons name (widget-value field)) 304 (push (cons name (widget-value field))
315 values))) 305 values)))
316 (t 306 (t
@@ -322,6 +312,25 @@
322 (push (cons (plist-get (cdr elem) :name) 312 (push (cons (plist-get (cdr elem) :name)
323 (plist-get (cdr elem) :value)) 313 (plist-get (cdr elem) :value))
324 values))) 314 values)))
315 ;; If we hit ENTER in a non-button field, include the value of the
316 ;; first submit button after it.
317 (unless (eq (car widget) 'push-button)
318 (let ((rest form)
319 (name (plist-get (cdr widget) :name)))
320 (when rest
321 (while (and rest
322 (or (not (consp (car rest)))
323 (not (equal name (plist-get (cdar rest) :name)))))
324 (pop rest)))
325 (while rest
326 (let ((elem (pop rest)))
327 (when (and (consp (car rest))
328 (eq (car elem) 'push-button))
329 (push (cons (plist-get (cdr elem) :name)
330 (plist-get (cdr elem) :value))
331 values)
332 (setq rest nil))))))
333 (debug values)
325 (let ((shr-base eww-current-url)) 334 (let ((shr-base eww-current-url))
326 (if (and (stringp (cdr (assq :method form))) 335 (if (and (stringp (cdr (assq :method form)))
327 (equal (downcase (cdr (assq :method form))) "post")) 336 (equal (downcase (cdr (assq :method form))) "post"))
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el
index b5e3b4246a3..c93357efd25 100644
--- a/lisp/gnus/shr.el
+++ b/lisp/gnus/shr.el
@@ -115,7 +115,6 @@ cid: URL as the argument.")
115(defvar shr-base nil) 115(defvar shr-base nil)
116(defvar shr-ignore-cache nil) 116(defvar shr-ignore-cache nil)
117(defvar shr-external-rendering-functions nil) 117(defvar shr-external-rendering-functions nil)
118(defvar shr-preliminary-table-render nil)
119 118
120(defvar shr-map 119(defvar shr-map
121 (let ((map (make-sparse-keymap))) 120 (let ((map (make-sparse-keymap)))
@@ -158,6 +157,7 @@ DOM should be a parse tree as generated by
158 (shr-state nil) 157 (shr-state nil)
159 (shr-start nil) 158 (shr-start nil)
160 (shr-base nil) 159 (shr-base nil)
160 (shr-preliminary-table-render 0)
161 (shr-width (or shr-width (window-width)))) 161 (shr-width (or shr-width (window-width))))
162 (shr-descend (shr-transform-dom dom)) 162 (shr-descend (shr-transform-dom dom))
163 (shr-remove-trailing-whitespace start (point)))) 163 (shr-remove-trailing-whitespace start (point))))
@@ -1167,7 +1167,6 @@ ones, in case fg and bg are nil."
1167 (setq cont (or (cdr (assq 'tbody cont)) 1167 (setq cont (or (cdr (assq 'tbody cont))
1168 cont)) 1168 cont))
1169 (let* ((shr-inhibit-images t) 1169 (let* ((shr-inhibit-images t)
1170 (shr-preliminary-table-render t)
1171 (shr-table-depth (1+ shr-table-depth)) 1170 (shr-table-depth (1+ shr-table-depth))
1172 (shr-kinsoku-shorten t) 1171 (shr-kinsoku-shorten t)
1173 ;; Find all suggested widths. 1172 ;; Find all suggested widths.
@@ -1189,7 +1188,6 @@ ones, in case fg and bg are nil."
1189 (frame-width)) 1188 (frame-width))
1190 (setq truncate-lines t)) 1189 (setq truncate-lines t))
1191 ;; Then render the table again with these new "hard" widths. 1190 ;; Then render the table again with these new "hard" widths.
1192 (setq shr-preliminary-table-render nil)
1193 (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths)) 1191 (shr-insert-table (shr-make-table cont sketch-widths t) sketch-widths))
1194 ;; Finally, insert all the images after the table. The Emacs buffer 1192 ;; Finally, insert all the images after the table. The Emacs buffer
1195 ;; model isn't strong enough to allow us to put the images actually 1193 ;; model isn't strong enough to allow us to put the images actually