org-googleclでblogger.comに日本語本文を投稿する方法
org-googlecl.elは便利です。 org-modeで書いた文章を自動でhtmlに変換して、その上blogger.comに投稿までしてくれます。
でも、意図通りに動かすには、少々カスタマイズが必要でした。 例えば、
日本語のタイトルに日本語の本文を、emacs上から投稿したい。
と思ったのですが、現段階でのorg-googlecl.clのコードではできず、 ちょっと変更を施して、
- 英語のタイトル
- 日本語の本文
という形でemacs上からbloggerに投稿できるようにしました。 パッチをみれば分かりますが、一時ファイルを使って文字コードをsjisからutf-8に変換しています。
Patch
diff --git a/org-googlecl.el b/org-googlecl.el
index 08aed34..38e5c4c 100644
--- a/org-googlecl.el
+++ b/org-googlecl.el
@@ -119,21 +119,25 @@ t"
(setq blogurl (nth 0 (org-split-string blogurl)))
(if (setq reposted (or googlecl-blog-auto-del (y-or-n-p "Delete existing blog entry?")))
(googlecl-delete-blog googlecl-blogname btitle)))))))
- (let* ((tmpfile (make-temp-file "googlecl"))
+ (let* ((tmpfile1 (make-temp-file "googlecl"))
+ (tmpfile2 (make-temp-file "googlecl-u-"))
(bhtml (if borg (org-export-as-html 5 nil nil 'string t) bbody))
+ (nkf-command (concat
+ "nkf -Swd " tmpfile1 " \> " tmpfile2))
(blog-command (concat
"google blogger post --blog \"" googlecl-blogname "\""
(if (length btitle) (concat " --title \"" btitle "\"")) " --user \"" googlecl-username "\" "
(if (length blabels) (concat " --tags \"" (concat blabels (if (and reposted (not(zerop(length googlecl-repost-tag)))) (concat "," googlecl-repost-tag) "")) "\" "))
- tmpfile)))
+ tmpfile2)))
(message "blog command is %s" blog-command)
- (with-temp-file tmpfile
+ (with-temp-file tmpfile1
(insert bhtml)
(goto-char (buffer-end 1))
(insert googlecl-footer))
-
+
+ (call-process-shell-command nkf-command nil nil t) ; waiting for generated tmpfile2 and go next line. (synchronous process)
(start-process-shell-command "googlecl-pid" nil blog-command))))
これで、python のスクリプト googlecl でも日本語本文を意図通りに通して、blogger.comに投稿できます。