括弧は空気、括弧は空気、括弧は空気…

tokyo-emacsに参加したので、せっかくだからメジャーモードと呼ばれるものを書いてみた。マイナーモードとの違いもよく分かってないけど、とりあえずできたよー。

引数にファイル名を取って、はてなグループのキーワードを編集できるRubyスクリプトを用意しといて、現在開いているバッファをその引数に投げてあげてC-cC-pでpostしてやるだけの簡単なお仕事をする関数とかです。

(defun hatena-group-keyword-mode ()
  "Major mode for hatena group keyword"
  (interactive)
  (kill-all-local-variables)
  (setq hatena-group-keyword-map (make-keymap))
  (define-key hatena-group-keyword-map "\C-c\C-p" 'post-hatena-group-keyword)
  (use-local-map  hatena-group-keyword-map)
  (setq major-mode 'hatena-group-keyword-mode)
  (setq mode-name "hatena-group-keyword-mode")
  )

(defun post-hatena-group-keyword ()
  "function to post hatena keyword"
  (interactive)
  (start-process "post-hatena-group-keyword"
         "*post-hatena-group-keyword*"
         "hgk.rb" (expand-file-name (buffer-name (window-buffer))))
  (message "finished posting to hatena group keyword."))

(provide 'hatena-group-keyword-mode)

メジャーモード童貞な僕でも、この辺見てたらなんとなくできたよ。まあ、できたのはへぼへぼだけどいいんだよw。