dpaste

是后知后觉了,一直想要一个好用的codebin,结果到现在才发现这么个网站── dpaste 。这是一个基于django和sqlite的站点,非常的简单,对于追求简单的我来说,恰对胃口。让我感觉最爽的一点,是emacs的绑定功能,el文件可以在 Emacs Binding 获得。在 .emacs 中加入 (require 'dpaste) 后,就可以使用 M-x dpaste-region/dpaste-buffer/dpaste-region-or-buffer 来把选定的代码或整个buffer直接发送到 dpaste ,代码的语言会根据当前emacs的运行模式设置,比如在python-mode下则使用python的格式。

不过这个el在我的Archlinux + emacs23上运行有一点问题,无法取得返回的链接地址,并且在发送纯文本格式时时出现错误。 经排查发现,一是正则对换行符没有处理,二是Plain格式的值应为空,所以制作了如下的补丁,给和我碰到同样问题的Emacser。:)

补丁@dpaste

http://dpaste.com/hold/92114/

由于在dpaste上如果无人访问,代码最多只保存30天,所以补丁在这儿还是得贴一下的。

--- dpaste.el.old   2009-05-10 20:37:00.000000000 +0800
+++ dpaste.el.new   2009-09-10 15:53:03.811309683 +0800
@@ -47,7 +47,8 @@
                                      (js2-mode . "JScript")
                                      (python-mode . "Python")
                                      (ruby-mode . "Ruby")
-                                     (text-mode . "Plain")
+                                     (text-mode . "")
                                      (sql-mode . "Sql")
                                      (sh-mode . "Bash")
                                      (xml-mode . "Xml")))
@@ -59,7 +60,7 @@
   (let* ((file (or (buffer-file-name) (buffer-name)))
          (name (file-name-nondirectory file))
          (ext (or (cdr (assoc major-mode dpaste-supported-modes-alist))
-                  (file-name-extension file)
                   ""))
          (output (generate-new-buffer "*dpaste*")))
     (shell-command-on-region begin end
@@ -67,7 +68,8 @@
                                 "' -F 'content=<-' http://dpaste.com/api/v1/")
                         output)
     (with-current-buffer output
-      (search-backward-regexp "^Location: \\([A-Za-z0-9]+.*\\)$")
+      (search-forward-regexp "^Location: \\([A-Za-z0-9:/\.\?&=]+\\)")
       (message "dpaste created: %s" (match-string 1))
       (kill-new (match-string 1)))
    (kill-buffer output)))

发表评论

评论备注:

  1. 留言时的头像是Gravatar提供的服务。
  2. By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. So, you don't fully own your words, so to speak.