Last active
September 15, 2026 05:24
-
-
Save alexover1/c5fa7de901c63516b483d900e7cdbc27 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
| ;; Automatically loads the compile command from a file in the current working directory. | |
| (defun alex/default-compile-command () | |
| (interactive) | |
| (let ((file (expand-file-name ".compile-command" default-directory))) | |
| (when (file-readable-p file) | |
| (setq-local compile-command | |
| (string-trim | |
| (with-temp-buffer | |
| (insert-file-contents file) | |
| (buffer-string)))) | |
| (message "Command set to: %s" compile-command)))) | |
| ;; Recompiles if compile-command is set, or else tries to set it to the contents of .compile-command. | |
| (defun alex/recompile () | |
| (interactive) | |
| (when (or (null compile-command) | |
| (string-empty-p compile-command)) | |
| (alex/default-compile-command)) | |
| (recompile)) | |
| (setq-default compile-command nil) | |
| ;; Enable compilation-mode keyboard shortcuts. | |
| (keymap-global-set "C-c c" #'compile) | |
| (keymap-global-set "C-c r" #'alex/recompile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment