Created
February 21, 2017 01:54
-
-
Save kumagi/2bda4dbdee8730136fd4c44b65878787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(require 'compile) | |
(defun upward-find-file (filename &optional startdir) | |
(let | |
((dirname (expand-file-name | |
(if startdir startdir "."))) | |
(found nil) | |
(top nil)) | |
(while (not (or found top)) | |
(if (string= (expand-file-name dirname) "/") | |
(setq top t)) | |
(if (file-exists-p (expand-file-name filename dirname)) | |
(setq found t) | |
(setq dirname (expand-file-name ".." dirname)))) | |
(if found dirname nil))) | |
(defun cmake-compile () | |
(interactive) | |
(setq builddir | |
(expand-file-name "build" | |
(upward-find-file "build" "."))) | |
(cd-absolute builddir) | |
(message "moved %s" builddir) | |
(compile (format "cmake .. -G Ninja && ninja" | |
(upward-find-file "build" ".")))) | |
(global-set-key "\C-cc" 'cmake-compile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment