Last active
August 29, 2015 14:08
-
-
Save ryzzn/8ff365d58f604b8e605e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defun* get-closest-pathname (&optional (file "Makefile")) | |
"Determine the pathname of the first instance of FILE starting from the current directory towards root. | |
This may not do the correct thing in presence of links. If it does not find FILE, then it shall return the name | |
of FILE in the current directory, suitable for creation" | |
(let ((root (expand-file-name "/"))) ; the win32 builds should translate this correctly | |
(expand-file-name file | |
(loop | |
for d = default-directory then (expand-file-name ".." d) | |
if (file-exists-p (expand-file-name file d)) | |
return d | |
if (equal d root) | |
return nil)))) | |
(defun my-cc-hook () | |
(local-set-key (kbd "M-`") (lambda () | |
(interactive) | |
(let ((default-directory | |
(file-name-directory (get-closest-pathname)))) | |
(compile "make -j10"))))) | |
(add-hook 'c-mode-common-hook 'my-cc-hook) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment