sandbox

Scala, Android, Architecture, Management, Service Design あたりを主戦場としております

anything-gist.el が便利

gist が emacs から直接編集できてとても便利なのですが、自分の環境ではどうにも動かなかったので少し修正。
変更点は大きく2点。

  • wget に --no-check-certificate オプションを追加
  • 既に gist が存在する場合 git pull する様に変更

https://gist.github.com/862360

@@ -156,7 +158,7 @@
           (delete-region (point-min) (point-max))
           (insert (shell-command-to-string
                 (concat
-                 "wget -q http://gist.github.com/"
+                 "wget --no-check-certificate http://gist.github.com/"
                  id
                  ".txt -O -")))
           (goto-char (point-min))
@@ -168,7 +170,7 @@
         (with-current-buffer gist-buffer
           (insert (shell-command-to-string
                 (concat
-                 "wget -q http://gist.github.com/"
+                 "wget --no-check-certificate -q http://gist.github.com/"
                  id
                  ".txt -O -")))
         (switch-to-buffer gist-buffer))))))
@@ -206,26 +208,26 @@
          ("view" . (lambda(obj-name)
                      (anything-gist-fetch
                        (nth 2 (split-string obj-name)))))
-         
+
          ("edit" . (lambda(obj-name)
+                     (setq gist-id (nth 2 (split-string obj-name)))
                      (setq gist-tmp-dir
-                           (concat temporary-file-directory
-                                   (nth 2 (split-string obj-name))))
+                           (concat temporary-file-directory gist-id))
                      (set-process-sentinel
                       (start-process
                        "anything-gist-clone"
                        "*anything-gist-clone*"
                        shell-file-name
-                       shell-command-switch 
-                       (concat "cd "
-                               temporary-file-directory
-                               " && git clone git@gist.github.com:"
-                               (nth 2 (split-string obj-name))
-                               ".git"))
+                       shell-command-switch
+                       (if (file-directory-p gist-tmp-dir)
+                           (concat "cd " gist-tmp-dir " && git pull")
+                           (concat "cd " temporary-file-directory
+                                   " && git clone git@gist.github.com:"
+                                   gist-id ".git")))
                       '(lambda
                          (process event)
                          (directory-walker  #'find-file-save-hook gist-tmp-dir)))

Reference

anything-gist.elをまたまたアップデート
http://sheephead.homelinux.org/2010/11/24/6396/