Saturday 19 July 2008

Emacs与Blogger

在Emacs里往Blogger发布,有几个办法,但大多都不很成熟。比如emacspeak的那套东西,用起来麻烦死了,也不支持中文。这个麻烦的方法应该算正统吧,因为直接用的Google给的服务接口。



还有个办法:

Emacs Jabber - GTalk - imified

用Imified机器人的Blogger服务;配好后用着还算方便。但扩展性不好。

还可以用发信的办法来写博客。在服务器端配好后,只需要发一封信就可以写一篇。信的主题对应博客标题,正文对应正文,还算自然吧。

发信写博客的扩展性很好。比如下面就是一个扩展:

(defun blogger ()
"Sent current subtree to my blogger"
(interactive)

;; Prepare subject
(org-back-to-heading)
(setq beg (posix-search-forward "]"))
(end-of-line)
(setq subject (buffer-substring beg (point)))

;; trim
(if (string-match "\\`[ \t\n]+" subject)

(setq subject (substring subject (match-end 0))))
;; Prepar mail body
(setq beg (+ 1 (point)))
(outline-end-of-subtree)
(setq body (buffer-substring beg (point)))
;; Draft a mail
(message-mail "username.password@blogger.com" subject)
(insert body)

;; Arrange the mail body
(goto-line 4)

;; Line 4 is at just ahead of the body
(while (= 0 (forward-line 1))
(if (> (- (line-end-position) (line-beginning-position)) fill-column)
(unfill-paragraph)))

;; Sent it to blogger directly if type blogger without C-u

(if (not current-prefix-arg)
(message-send-and-exit)))

这个扩展写的很粗糙,也只是针对我的使用而写,不通用。不过已经可以满足我的需求了。

No comments: