Subject: bug#15703: [PATCH 1/8] EWW: Support user defined representation for checkbox.

From: Rüdiger Sonderfeld <[email-masked]>
Date: Fri, 25 Oct 2013 01:43:17 +0200

Unicode provides BALLOT BOX* symbols to represent check boxes.

* lisp/net/eww.el (eww-form-checkbox-selected-symbol): New
  customizable variable.
  (eww-form-checkbox-symbol): New customizable variable.
  (eww-form-checkbox): Use `eww-form-checkbox-selected-symbol' and
  `eww-form-checkbox-symbol'.
  (eww-toggle-checkbox): Use `eww-form-checkbox-selected-symbol' and
  `eww-form-checkbox-symbol'.

Signed-off-by: Rüdiger Sonderfeld <[email-masked]>
---
 lisp/net/eww.el | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 573715e..989cd2e 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -56,6 +56,25 @@ (defcustom eww-download-path "~/Downloads/"
   :group 'eww
   :type 'string)
 
+(defcustom eww-form-checkbox-selected-symbol "[X]"
+  "Symbol used to represent a selected checkbox.
+See also `eww-form-checkbox-symbol'."
+  :version "24.4"
+  :group 'eww
+  :type '(choice (const "[X]")
+                 (const "☒")            ; Unicode BALLOT BOX WITH X
+                 (const "☑")            ; Unicode BALLOT BOX WITH CHECK
+                 string))
+
+(defcustom eww-form-checkbox-symbol "[ ]"
+  "Symbol used to represent a checkbox.
+See also `eww-form-checkbox-selected-symbol'."
+  :version "24.4"
+  :group 'eww
+  :type '(choice (const "[ ]")
+                 (const "☐")            ; Unicode BALLOT BOX
+                 string))
+
 (defface eww-form-submit
   '((((type x w32 ns) (class color))	; Like default mode line
      :box (:line-width 2 :style released-button)
@@ -579,8 +598,8 @@ (defun eww-form-submit (cont)
 (defun eww-form-checkbox (cont)
   (let ((start (point)))
     (if (cdr (assq :checked cont))
-	(insert "[X]")
-      (insert "[ ]"))
+	(insert eww-form-checkbox-selected-symbol)
+      (insert eww-form-checkbox-symbol))
     (add-face-text-property start (point) 'eww-form-checkbox)
     (put-text-property start (point) 'eww-form
 		       (list :eww-form eww-form
@@ -801,9 +820,9 @@ (defun eww-toggle-checkbox ()
 	  (if (plist-get input :checked)
 	      (progn
 		(plist-put input :checked nil)
-		(eww-update-field "[ ]"))
+		(eww-update-field eww-form-checkbox-symbol))
 	    (plist-put input :checked t)
-	    (eww-update-field "[X]"))))
+	    (eww-update-field eww-form-checkbox-selected-symbol))))
       ;; Radio button.  Switch all other buttons off.
       (let ((name (plist-get input :name)))
 	(save-excursion
@@ -813,9 +832,9 @@ (defun eww-toggle-checkbox ()
 	      (if (not (eq (cdr elem) input))
 		  (progn
 		    (plist-put input :checked nil)
-		    (eww-update-field "[ ]"))
+		    (eww-update-field eww-form-checkbox-symbol))
 		(plist-put input :checked t)
-		(eww-update-field "[X]")))))
+		(eww-update-field eww-form-checkbox-selected-symbol)))))
 	(forward-char 1)))))
 
 (defun eww-inputs (form)
-- 
1.8.4.1