diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 44aff09..9bc273f 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -49,8 +49,6 @@ (startup-redirect-eln-cache (convert-standard-filename rhjr/paths/eln-cache))) -(load-theme 'misterioso) - ;;; rhjr/defaults (setq-default initial-major-mode 'text-mode @@ -234,12 +232,16 @@ ;;; rhjr/programming (defconst rhjr/c-style `((c-basic-offset . 2) + (c-hanging-braces-alist . ((defun-open))) (c-offsets-alist .((statement . 0) (statement-cont . 0) (substatement-open . 0) (arglist-intro . 2) (case-label . 2) - (label . 0))))) + (label . 0) + + ;; functions + (func-decl-cont . 0))))) (defun rhjr/set-c-style () "" @@ -255,6 +257,51 @@ (setq-default show-trailing-whitespace t) (add-hook 'before-save-hook 'delete-trailing-whitespace) +;;rhjr/comp +(setq compilation-directory-locked nil) + +(defun find-project-directory-recursive (command) + "Recursively search upward until COMMAND exists." + (if (file-exists-p command) + t + (let ((parent (file-name-directory (directory-file-name default-directory)))) + (unless (or (null parent) (string= parent default-directory)) + (cd parent) + (find-project-directory-recursive command))))) + +(defun lock-compilation-directory () + (interactive) + (setq compilation-directory-locked t) + (message "Compilation directory is locked.")) + +(defun unlock-compilation-directory () + (interactive) + (setq compilation-directory-locked nil) + (message "Compilation directory is roaming.")) + +(defun find-project-directory (command) + (let ((start-dir default-directory)) + (switch-to-buffer-other-window "*compilation*") + (if compilation-directory-locked + (cd last-compilation-directory) + (cd start-dir) + (find-project-directory-recursive command) + (setq last-compilation-directory default-directory)))) + +(defun run-project-command (command) + "Run COMMAND from the project root without prompting." + (interactive) + (find-project-directory command) + (compile command) + (other-window 1)) + +(global-set-key [f1] (lambda () (interactive) + (run-project-command "./build.sh"))) + +(global-set-key [f2] (lambda () (interactive) + (run-project-command "./start.sh"))) + + ;;rhjr/fix (setq minibuffer-prompt-properties ;; cursor in minibuffer-prompt '(read-only t cursor-intangible t face minibuffer-prompt))