(mixi-replace-tab-and-space-to-nbsp): New user option.
authorbg66 <bg66>
Fri, 26 Dec 2008 02:44:09 +0000 (02:44 +0000)
committerbg66 <bg66>
Fri, 26 Dec 2008 02:44:09 +0000 (02:44 +0000)
(mixi-replace-tab-and-space-to-nbsp): New function.
(mixi-post-diary): Use it.
(mixi-post-topic): Ditto.
(mixi-post-comment): Ditto.
(mixi-post-message): Ditto.

ChangeLog
mixi-ja.texi
mixi.el

index 35c06e0..a4800d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-12-26  OHASHI Akira  <bg66@koka-in.org>
+
+       * mixi.el (mixi-replace-tab-and-space-to-nbsp): New user option.
+       (mixi-replace-tab-and-space-to-nbsp): New function.
+       (mixi-post-diary): Use it.
+       (mixi-post-topic): Ditto.
+       (mixi-post-comment): Ditto.
+       (mixi-post-message): Ditto.
+
 2008-12-09  OHASHI Akira  <bg66@koka-in.org>
 
        * mixi-gnus.el (toplevel): Avoid warnings when compiling.
index e276ed2..c14f355 100755 (executable)
@@ -1437,6 +1437,11 @@ mixi \e$B$N%5%$%H$O<+F0%D!<%k$J$I$GC;;~4V$KO"B3$7$F%"%/%;%9$7$?>l9g!"$=$N@\\e(B
 \e$B@\B3$r5qH]$5$l$?>l9g$KBT5!$9$k\e(B@emph{\e$BIC?t\e(B}\e$B$r;XDj$7$^$9!#\e(B
 @end defopt
 
+@defopt mixi-replace-tab-and-space-to-nbsp
+\e$B<g$K\e(B mixi \e$B$X$NEj9F;~!"@07A$5$l$?>uBV$rJ]$D$?$a$K%?%V$H%9%Z!<%9$rJ8;z<BBN\e(B
+\e$B;2>H$G$"$k\e(B @code{&nbsp;} \e$B$XCV49$9$k$+$I$&$+$r;XDj$7$^$9!#\e(B
+@end defopt
+
 @defopt mixi-cache-expires
 mixi \e$B%*%V%8%'%/%H$N%-%c%C%7%e$NM-8z4|8B$r;XDj$7$^$9!#\e(B
 
diff --git a/mixi.el b/mixi.el
index 6b6bd2e..426b276 100644 (file)
--- a/mixi.el
+++ b/mixi.el
   (autoload 'w3m-retrieve "w3m")
   (autoload 'url-retrieve-synchronously "url"))
 
-(defconst mixi-revision "$Revision: 1.201 $")
+(defconst mixi-revision "$Revision: 1.202 $")
 
 (defgroup mixi nil
   "API library for accessing to mixi."
@@ -221,6 +221,11 @@ Increase this value when unexpected error frequently occurs."
   :type 'number
   :group 'mixi)
 
+(defcustom mixi-replace-tab-and-space-to-nbsp t
+  "*If non-nil, replace tab and space to &nbsp; for keeping formatted."
+  :type 'boolean
+  :group 'mixi)
+
 (defcustom mixi-cache-expires nil
   "*Seconds for expiration of a cached object."
   :type '(radio (integer :tag "Expired seconds")
@@ -565,6 +570,18 @@ Increase this value when unexpected error frequently occurs."
       (setq pos (+ (match-end 0) 1)))
     string))
 
+(defun mixi-replace-tab-and-space-to-nbsp (string)
+  (when mixi-replace-tab-and-space-to-nbsp
+    (let ((pos 0))
+      (while (or (string-match "\t" string pos)
+                (string-match " " string pos))
+       (if (string= (match-string 0 string) "\t")
+           (setq string (replace-match (make-string tab-width ?\ )
+                                       nil nil string))
+         (setq string (replace-match "&nbsp;" nil nil string))
+         (setq pos (+ (match-end 0) 1))))
+      string)))
+
 ;; Object.
 (defconst mixi-object-prefix "mixi-")
 
@@ -1455,7 +1472,8 @@ Increase this value when unexpected error frequently occurs."
     (setq fields `(("post_key" . ,post-key)
                   ("id" . ,(mixi-friend-id (mixi-make-me)))
                   ("diary_title" . ,title)
-                  ("diary_body" . ,content)
+                  ("diary_body" . ,(mixi-replace-tab-and-space-to-nbsp
+                                    content))
                   ("submit" . "confirm")))
     (with-mixi-post-form (mixi-post-diary-page) fields
       (unless (re-search-forward mixi-post-succeed-regexp nil t)
@@ -1920,7 +1938,8 @@ Increase this value when unexpected error frequently occurs."
        (mixi-post-error 'cannot-find-key community)))
     (setq fields `(("post_key" . ,post-key)
                   ("bbs_title" . ,title)
-                  ("bbs_body" . ,content)
+                  ("bbs_body" . ,(mixi-replace-tab-and-space-to-nbsp
+                                  content))
                   ("submit" . "confirm")))
     (with-mixi-post-form (mixi-post-topic-page community) fields
       (unless (re-search-forward mixi-post-succeed-regexp nil t)
@@ -2519,10 +2538,12 @@ Increase this value when unexpected error frequently occurs."
        (setq fields
              `(("post_key" . ,post-key)
                ("owner_id" . ,(mixi-friend-id (mixi-diary-owner parent)))
-               ("comment_body" . ,content)
+               ("comment_body" . ,(mixi-replace-tab-and-space-to-nbsp
+                                   content))
                ("submit" . "confirm")))
       (setq fields `(("post_key" . ,post-key)
-                    ("comment" . ,content)
+                    ("comment" . ,(mixi-replace-tab-and-space-to-nbsp
+                                   content))
                     ("submit" . "confirm"))))
     (with-mixi-post-form (funcall page parent) fields
       (unless (re-search-forward mixi-post-succeed-regexp nil t)
@@ -2725,7 +2746,7 @@ Increase this value when unexpected error frequently occurs."
        (mixi-post-error 'cannot-find-key friend)))
     (setq fields `(("post_key" . ,post-key)
                   ("subject" . ,title)
-                  ("body" . ,content)
+                  ("body" . ,(mixi-replace-tab-and-space-to-nbsp content))
                   ("yes" . "¡¡Á÷¡¡¿®¡¡")
                   ("submit" . "confirm")))
     (with-mixi-post-form (mixi-post-message-page friend) fields