hgのコマンドが面倒だったので適当に補完(その2くらい)

 前に書いてたマーキュリアルの簡易コマンド実行補完機能みたいなのをちょっと変えたりしてたので、一応メモ。何が変わったかというと対して変わってないんだけど、書式を忘れるとか-mとかオプション入れるのが段々面倒になってきたので、commitして-m入れ忘れてたらミニバッファでメッセージを聞いてくるようにとかしてみたりした。

(defun hg-comp()
  (interactive)
  (define-key minibuffer-local-completion-map #\SPC 'self-insert-command)
  (let* ((comp-list '("add" "annotate" "cat" "commit" "copy"
         "clone" "diff" "grep" "init" "locate"
         "log" "manifest" "pull" "push" "remove"
         "rename" "status" "update" "help"))
         (str (completing-read "hg " comp-list :must-match nil))
         (one-more nil))
    (cond ((string= str "commit")
           (setq str (concat str "-m \""(read-string "message ") "\"")))
          ((string= str "grep")
           (setq str (concat str " \"" (read-string "pattern ") "\" "
                             (buffer-name (selected-buffer)))))
          ((or (string= str "status")
               (string= str "update")
               (string= str "help"))
           (setq one-more t)))
    (execute-shell-command (concat "hg " str ) nil "*hg-cmd*")
    (if one-more (hg-comp))
  ))