[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: automatically filling out WordPress comment fields



>>>>> In [emacs-w3m : No.10676] jidanni@xxxxxxxxxxx wrote:

j> The question is how can I automatically fill in the first three fields
j> with my personal details, which never change?

> On http://lorelle.wordpress.com/2007/10/31/blog-struggles-when-are-too-many-comments-too-many-comments/#comment
> I tried

[...]

> Anyway, there are slight variations in the form, e.g.,
> http://ma.tt/2009/01/venture-destruction/#comment
> therefore I will also need to erase any text found first too.

I'm not sure it is the right approach but how about this plan?

Add the following two user options to somewhere in w3m-form.el:

--8<---------------cut here---------------start------------->8---
(defcustom w3m-form-values nil
  "Alist of form names and values to override.
Values override existing ones in forms of names unconditionally."
  :group 'w3m
  :type '(repeat (cons :format "%v"
		       (string :tag "Name") (string :tag "Value"))))

(defcustom w3m-form-values-default nil
  "Alist of form names and values used as the default.
Values will be used in forms of names when they are empty."
  :group 'w3m
  :type '(repeat (cons :format "%v"
		       (string :tag "Name") (string :tag "Value"))))
--8<---------------cut here---------------end--------------->8---

And modify `w3m-form-parse-and-fontify' as follows:

--8<---------------cut here---------------start------------->8---
--- w3m-form.el~	2009-01-04 21:39:55 +0000
+++ w3m-form.el	2009-02-05 23:21:11 +0000
@@ -702,8 +702,10 @@
 			       no_effect       ; map
 			       name value)
 	  (incf id)
-	  (when value
-	    (setq value (w3m-decode-entities-string value)))
+	  (setq value (or (cdr (assoc name w3m-form-values))
+			  (if (zerop (length value))
+			      (cdr (assoc name w3m-form-values-default))
+			    (w3m-decode-entities-string value))))
 	  (save-excursion
 	    (search-forward "</input_alt>")
 	    (setq end (match-beginning 0)))
--8<---------------cut here---------------end--------------->8---

Probably adding this to ~/.emacs-w3m.el is yours (I verified):

--8<---------------cut here---------------start------------->8---
(setq w3m-form-values
      '(("author" . "jidanni")
	("email" . "jidanni@xxxxxxxxxxx")
	("url" . "http://jidanni.org/";)))
--8<---------------cut here---------------end--------------->8---

Japanese:
フォームに記入する名前やメールアドレスなどを毎回記入するのは面倒
なので、自動化してしまおうというアイデアです。上記のやり方は変じゃ
ないでしょうか?