上記記事を読んで自分革命がありました。
と、いうことで、私は多くの日常ワークを make
で自動化しています。目的に応じて選択実行するために hydra
でメニュー化しています。
;; Hydra for make command
(leaf *user-make-configulation
:mode (("\\.mak\\'" "makefile\\'") . makefile-mode)
:hydra
(hydra-make
(:hint nil :exit t)
"
make:_k_ _u_psftp _m_ove _d_raft _b_klog _g_it _s_ort _c_lean 🐾
"
("k" my:make-k)
("u" my:make-upsftp)
("m" my:make-move)
("d" my:make-draft)
("b" my:make-bklog)
("g" my:make-git)
("s" my:make-sort)
("c" my:make-clean)
("<muhenkan>" nil))
:init
(setq compilation-scroll-output t)
(setq compilation-always-kill t)
(setq compilation-finish-functions 'compile-autoclose)
(defun compile-autoclose (buffer string)
"Automatically close the compilation buffer."
(cond ((string-match "finished" string)
(bury-buffer "*compilation*")
(delete-other-windows)
(message "Build successful."))
(t (message "Compilation exited abnormally: %s" string)))))
必要な make
実行コマンドを定義します。
例えば、詳細に commit message
を残さなくてもいい Gitリポジトリは、magit
は使わずに make
で自動コミットします。
make git
で実行されます。
# makefile for auto commit
git:
git add . && git diff --cached --exit-code --quiet && echo "\nnothing to commit, working tree clean!"|| \
git commit -a -m "Updated: `date +'%Y-%m-%d %H:%M:%S'`" && \
git push origin master
実行関数は、コマンドを実行しながら、Emacs上で別の作業をさせることができる compile
を使います。
compile
コマンドの実行環境として以下を設定しています。
*compilation*
バッファーを自動スクロールさせる*compilation*
バッファーを自動で閉じる(setq compilation-scroll-output t)
(setq compilation-always-kill t)
(setq compilation-finish-functions 'compile-autoclose)
(defun compile-autoclose (buffer string)
"Automatically close the compilation buffer."
(cond ((string-match "finished" string)
(bury-buffer "*compilation*")
(delete-other-windows)
(message "Build successful."))
(t (message "Compilation exited abnormally: %s" string))))
実行コマンドの一例は以下のとおり。
;; My make command functions
(defun my:make-k ()
"Make k."
(interactive)
(compile "make -k"))
(defun my:make-draft ()
"Make kinnei draft."
(interactive)
(compile "make df"))
(defun my:make-upsftp ()
"Make upfstp."
(interactive)
(compile "make up"))
(defun my:make-move ()
"Make move."
(interactive)
(compile "make mv"))
(defun my:make-bklog ()
"Make bklog."
(interactive)
(compile "make bk"))
(defun my:make-git ()
"Make git."
(interactive)
(compile "make git"))
(defun my:make-sort ()
"Make sort for filelist."
(interactive)
(compile "make sort")
(find-file "~/Dropbox/GH/upsftp/filelist.txt")
(goto-char (point-min)))
(defun my:make-clean ()
"Make clean."
(interactive)
(compile "make clean"))