Run the shell command asynchronously that you specified when you save the file.
Emacs Lisp
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Run the shell command asynchronously that you specified when you save the file. And there flymake autotest, is Guard as a similar tool.

  1. Specify target file's regexp and command to execute when the save
  2. Can temporarily suspend the execution of the command
  3. Emacs is running on the OS of all work
  4. It is possible to register a temporary command disappear restart Emacs
  5. Caused by rewriting the file does not occur by external tools, malfunctions of the command disappointing


Requires emacs-deferred.

People can use the auto-install. Please execute the following elisp.

(auto-install-from-url "")
(auto-install-from-url "")

Also put the location of the load path through the following files or.

Initial setting

(require 'auto-shell-command)

;; Set of key bindings
(global-set-key (kbd "C-c C-m") 'ascmd:toggle) ; Temporarily on/off auto-shell-command run
(global-set-key (kbd "C-c C-,") 'ascmd:popup)  ; Pop up '*Auto Shell Command*'
(global-set-key (kbd "C-c C-.") 'ascmd:exec)   ; Exec-command specify file name

;; ;; Popup on errors
;; (push '("*Auto Shell Command*" :height 20 :noselect t) popwin:special-display-config)

;; ;; Notification of results to Growl (optional)
;; (defun ascmd:notify (msg) (deferred:process-shell (format "growlnotify -m %s -t emacs" msg))))

Command list setting

;; Register command
(ascmd:add '("Target file's regexp" "Command to be executed when the file save"))
;; A simple example
(ascmd:add '("/path/to/dir" "ls"))      ; After you have run the `ls` save the following files: '/path/to/dir'
;; High priority S-exp was evaluated after
(ascmd:add '("/path/to/dir/foo.c" "ls -la"))      ; 'foo.c' will only run the `ls-la`
;; Special variables
(ascmd:add '("/path/to/dir/.*\.c" "cat $FILE"))      ; Other .c file run the `cat FILE_NAME`

Special variables

  • $FILE ... "/path/to/dir/foo.c" -> "foo.c"
  • $DIR ... "/path/to/dir/foo.c" -> "/path/to/dir/"


Configuration example of C

;; High priority under
(ascmd:add '("/path/to/dir"                  "make"))     ; Exec 'make'
(ascmd:add '("/path/to/dir/.gitignore"       "make run")) ; If you touch beneath the root folder '. gitignore' -> 'make run'
(ascmd:add '("/path/to/dir/doc"              "make doc")) ; If you touch the folloing 'doc' -> 'make doc'
(ascmd:add '("/path/to/dir/BBB"              "(cd /path/to/dir/AAA && make && cd ../BBB && make)")) ; When you build the BBB, need to build the first AAA

Configuration example of Ruby

(ascmd:add '("/path/test/runner.rb"          "rake test"))                     ; If you touch 'test/runner.rb' -> 'rake test' (Take time)
(ascmd:add '("/path/test/test_/.*\.rb"       "ruby -I../lib -I../test $FILE")) ; If you touch 'test/test_*.rb', test by itself only the edited file (Time-saving)

Cooperation with the browser

(ascmd:add '("Resources/.*\.js" "wget -O /dev/null")) ; If you touch the following: 'Resources/*.js' access to ''




Copyright (C) 2012, 2013 ongaeshi <>