EMACS & 程序 编程点滴...

天下难事必作于易,天下大事必作于细

Lastupdated: 2009-09-24

用Emacs写Blog

TOPEmacs写Bolg工具

既然emacs是一个万能的编辑器,那么一定能够用来写Blog了,现在有以下两款也许能适合你。

TOPweblogger.el

weblogger.el主要使用了以下两个elisp:
  • weblogger.el1
  • xml-rpc.el

安装很简单

1
2
3
cd ~/.emacs.d/
cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/emacsweblogs
co -d weblogger weblogger/lisp

在你的.emacs中

1
2
(add-to-list 'load-path "~/.emacs.d/weblogger") ;; 更改为你安装的路径
(require 'weblogger)

即可。

1
2
3
4
5
6
7
;; 初期设置
M-x weblogger-setup-weblog
;; 1) 输入Blog的Endpoint,WordPress的情况下即xmlrpc.php文件
Server Endpoint (URL): http://xxxx/xmlrpc.php
;; 2) 用户名,密码
Username: xxxx
Password for webblog server: ......

准备好了,就让我们开始写第一次用emacs来投稿吧。

M-x weblogger-start-entry

以下是weblogger的快捷键:

快捷键 功能
C-xC-s 正式发布
C-cC-c 作为草稿发布
C-cC-n 查看下一个发布的文章
C-cC-p 查看前一个发布的文章
M-g 查看最后一个发布的文章

使用中,发现xml-rpc.el在emacs23下面有bug—html的tag不能正常发布。通过这个patch可以解决这个问题。

后来又发现有时候会插入奇怪的回车符,那么这样修改了一下:

1
2
3
(add-hook 'weblogger-entry-mode-hook
    (lambda ()
     (setq fill-column 4000)))

TOPBloggerPost

BloggerPost利用了AtomPP和XML-RPC,通过emacs来发布博客。具有以下特征:
  • 支持Blogger、Movable Type、TypePad、WordPress的博客。
  • 支持HTML、RD、Wiki等多种格式。
  • 基本的发布,编辑,删除功能。
  • 支持分类,标签。
  • 支持Trackback(引用)送信。
  • 更新Ping送信功能。
  • 支持syntax highlight、ASIN等扩展符号。
  • 可管理多个博客。
  • 通过Ruby实现。

看上去比 Weblogger 好像强大许多。接下来让我们试一试。

TOP安装

因为BloggerPost是由Ruby实现的,同时需要许多Ruby实现的软件包,所以我们先从安装Ruby开始:(以windows下安装为 例,linux上基本相同,甚至还要简单)。windows上最好安装有Cygwin。

1. 在这里下载Ruby for Windows版,安装至 c:/ruby 下,之后将 c:/ruby/bin 放到PATH路径下。这里下载的是 1.8.7-p72版。 而最新的1.9.1版因为引入了encoding,所以在编译配置的时候总出现“invalid byte sequence in GBK”的错误,所以建议还是先用低版本的编译。

2. 下载el4r, 并按以下方式安装。(el4r是一个让emacs支持ruby语言的扩展)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ tar xzf el4r-1.0.4.tar.gz
$ cd el4r-1.0.4
$ ruby setup.rb
$ ...

# 通过作者提供的环境配置工具el4r-rctool,自动配置.emacs
$ ruby -S bin/el4r-rctool -p
cp C:/.el4rrc.rb backup/.el4rrc.rb.backup
Generating backup/.el4rrc.rb.new...
cp C:/.emacs backup/.emacs.backup
Generating backup/.emacs.new...
cp C:/.el4r/init.rb backup/__absolute__/.el4r/init.rb.backup
Generating backup/__absolute__/.el4r/init.rb.new...

$ ruby -S bin/el4r-rctool -i
cp backup/.el4rrc.rb.new C:/.el4rrc.rb
cp backup/.emacs.new C:/.emacs
cp backup/__absolute__/.el4r/init.rb.new C:/.el4r/init.rb

3. 下载QDBM, 并安装。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$ tar xzf qdbm-1.8.77.tar.gz
$ cd qdbm-1.8.77
$ ./configure && make win && make install-win
#================================================================
# Configuring QDBM version 1.8.77.
#================================================================
checking for gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for ld... /bin/ld
checking for ar... /bin/ar
checking for main in -lc... yes
checking for main in -lqdbm... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating LTmakefile
config.status: creating qdbm.spec
config.status: creating qdbm.pc
#================================================================
# Ready to make.
#================================================================
...

4. 安装BloggerPost。

1
2
$ cd ../bloggerpost
$ ruby setup.rb

TOP设定

C盘下(home目录)建立 .bloggerpost 目录,在之下新建一个config.yml文件:

具体设置可以参考bloggerpost目录下的config.yml.sample文件。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
defaultstyle: bhtml
account:
  - name: wordpress_account
    user: xxxx
    passwd: xxxxxx
ping:
  - name: default
    list:
      - http://blogsearch.google.com/ping/RPC2
      - http://api.my.yahoo.co.jp/RPC2
      - http://rpc.technorati.jp/rpc/ping
      - http://blog.goo.ne.jp/XMLRPC
      - http://ping.bloggers.jp/rpc/
      - http://bulkfeeds.net/rpc
      - http://www.blogpeople.net/servlet/weblogUpdates
      - http://ping.ask.jp/xmlrpc.m
blog:
  default: wordpress
  list:
  - name: wordpress
    title: "YIFEIYANG"
    service: wordpress
    account: xxxx
    url: http://wwww.yifeiyang.net
    posturl: http://www.yifeiyang.net/wp/xmlrpc.php

TOP使用

TOP草稿模式
启动草稿模式:
M-x bloggerpost-draft
快捷键 功能
w 进入bloglist模式
e 编辑当前高亮的文章
C-cC-c 发布文章
C-cC-k 删除文章
C-xC-s 保存文章
C-cC-p 预览当前编辑文章
C-cC-z 保存文章并退出
TOPbloglist模式
启动bloggerpost:
M-x bloggerpost
快捷键 功能
空格,回车 查询投稿一览分类,按回车进入投稿一览entrylist
w 建立新文章
s 更新
G 检索
b 用浏览器打开
q 退出
TOPentrylist模式
快捷键 功能
回车 表示当前投稿文章
n 下移
p 上移
w 建立新文章
s 更新
g 当前分类中搜索
G 所有投稿文章中搜索
b 用浏览器打开
q 退出
TOP扩展符号

1. 在这里提供了两个el文件打包下载,且已经打了补丁。

© www.yifeiyang.net
net tracking

                                                                                                 stats