#+TITLE: Run drone test suite from emacs
#+DATE: 2016-11-15 12:00:00 UTC
#+DESCRIPTION: Example lisp code that run drone in a shell and outputs into a buffer the results.
#+FILETAGS: emacs:lisp
#+CATEGORY: lisp
#+SLUG: run-drone-test-suite-from-emacs 
#+BEGIN_COMMENT
.. title: Run drone test suite from emacs  
.. slug: run-drone-test-suite-from-emacs 
.. date: 2016-11-15 12:00:00 UTC
.. tags: lisp, emacs
.. category: lisp
.. link: 
.. description: Example lisp code that run drone in a shell and outputs into a buffer the results.  
.. type: text
#+END_COMMENT

The first function =drone-root= simply searches for =.drone.yml= by searching up the file system tree from the current files path.

The second function =drone-exec= runs =drone exec= and output the results to a new buffer called =*drone:=.


#+BEGIN_SRC emacs-lisp
(defun drone-root ()
  (or (locate-dominating-file default-directory ".drone.yml")
      (error "Missing .drone.yml not found in directory tree")))

;;;###autoload
(defun drone-exec ()
  "Run \"drone exec\" where .drone.yml is found."
  (interactive)
  (let ((default-directory (drone-root)))
    (with-current-buffer (get-buffer-create (concat "*drone: " default-directory "*"))
      (compilation-start (format "drone exec")
        nil
        (lambda (_) (buffer-name))))))
#+END_SRC

