using emacs’ (compile) command to track errors

Development Consulting Articles

News

For a mod_perl project I’m working on I wanted a way to track the apache error log and jump to the source of the errors from emacs.

Fortunately, emacs’ (compile) command makes this very easy:

;; restarts apache and track the error log
(defun apache-restart-and-tail ()
      (interactive)
      (compile "sudo /etc/init.d/httpd restart && sudo tail -f /var/log/httpd/error_log"))

;; key binding
(global-set-key (kbd "<C-kp-enter>") 'apache-restart-and-compile)