config-compile.el (3655B)
1 ;;; config-compile.el --- -*- lexical-binding: t; -*- 2 ;;; Commentary: 3 ;;; Generic compilation configuration 4 ;;; Code: 5 6 (defun my-recompile (args) 7 (interactive "P") 8 (cond 9 ((eq major-mode #'emacs-lisp-mode) 10 (call-interactively 'eros-eval-defun)) 11 ((bound-and-true-p my-vterm-command) 12 (my-vterm-execute-region-or-current-line my-vterm-command)) 13 ((get-buffer "*compilation*") 14 (with-current-buffer"*compilation*" 15 (recompile))) 16 ((get-buffer "*Go Test*") 17 (with-current-buffer "*Go Test*" 18 (recompile))) 19 ((and (eq major-mode #'go-mode) 20 buffer-file-name 21 (string-match 22 "_test\\'" (file-name-sans-extension buffer-file-name))) 23 (my-gotest-maybe-ts-run)) 24 ((and (get-buffer "*cargo-test*") 25 (boundp 'my-rustic-current-test-compile) 26 my-rustic-current-test-compile) 27 (with-current-buffer "*cargo-test*" 28 (rustic-cargo-test-run my-rustic-current-test-compile))) 29 ((get-buffer "*cargo-run*") 30 (with-current-buffer "*cargo-run*" 31 (rustic-cargo-run-rerun))) 32 ((get-buffer "*pytest*") 33 (with-current-buffer "*pytest*" 34 (recompile))) 35 ((eq major-mode #'python-mode) 36 (compile (concat python-shell-interpreter " " (buffer-file-name)))) 37 ((call-interactively 'compile)))) 38 39 ;; UseCompile 40 (use-package compile 41 :unless noninteractive 42 :commands (compile) 43 :preface 44 (autoload 'ansi-color-apply-on-region "ansi-color") 45 46 (defvar compilation-filter-start) 47 48 (defun vde/colorize-compilation-buffer () 49 (unless (or (derived-mode-p 'grep-mode) 50 (derived-mode-p 'ag-mode) 51 (derived-mode-p 'rg-mode)) 52 (let ((inhibit-read-only t)) 53 (ansi-color-apply-on-region compilation-filter-start (point))))) 54 :config 55 (setq-default compilation-scroll-output t 56 ;; I'm not scared of saving everything. 57 compilation-ask-about-save nil 58 ;; Automatically scroll and jump to the first error 59 ;; compilation-scroll-output 'next-error 60 ;; compilation-scroll-output 'first-error 61 ;; compilation-auto-jump-to-first-error t 62 ;; Skip over warnings and info messages in compilation 63 compilation-skip-threshold 2 64 ;; Don't freeze when process reads from stdin 65 compilation-disable-input t 66 ;; Show three lines of context around the current message 67 compilation-context-lines 3 68 ) 69 (add-hook 'comint-output-filter-functions 70 'comint-watch-for-password-prompt) 71 (setq-default comint-password-prompt-regexp 72 (concat 73 "\\(" 74 "^Enter passphrase.*:" 75 "\\|" 76 "^Repeat passphrase.*:" 77 "\\|" 78 "[Pp]assword for '[a-z0-9_-.]+':" 79 "\\|" 80 "\\[sudo\\] [Pp]assword for [a-z0-9_-.]+:" 81 "\\|" 82 "[a-zA-Z0-9]'s password:" 83 "\\|" 84 "^[Pp]assword:" 85 "\\|" 86 "^[Pp]assword (again):" 87 "\\|" 88 ".*\\([Ww]ork\\|[Pp]ersonal\\).* password:" 89 "\\|" 90 "Password for '([^()]+)' GNOME keyring" 91 "\\|" 92 "Password for 'http.*github.*':" 93 "\\)")) 94 (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer)) 95 96 (use-package emacs 97 :bind 98 (:map prog-mode-map 99 ("C-M-<return>" . compile) 100 ("C-<return>" . my-recompile))) 101 102 (provide 'config-compile) 103 ;;; config-compile.el ends here