fedora-csb-system-manager
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 'compilation-finish-functions #'alert-after-finish-in-background)
70 (add-hook 'comint-output-filter-functions
71 'comint-watch-for-password-prompt)
72 (setq-default comint-password-prompt-regexp
73 (concat
74 "\\("
75 "^Enter passphrase.*:"
76 "\\|"
77 "^Repeat passphrase.*:"
78 "\\|"
79 "[Pp]assword for '[a-z0-9_-.]+':"
80 "\\|"
81 "\\[sudo\\] [Pp]assword for [a-z0-9_-.]+:"
82 "\\|"
83 "[a-zA-Z0-9]'s password:"
84 "\\|"
85 "^[Pp]assword:"
86 "\\|"
87 "^[Pp]assword (again):"
88 "\\|"
89 ".*\\([Ww]ork\\|[Pp]ersonal\\).* password:"
90 "\\|"
91 "Password for '([^()]+)' GNOME keyring"
92 "\\|"
93 "Password for 'http.*github.*':"
94 "\\)"))
95 (add-hook 'compilation-filter-hook #'vde/colorize-compilation-buffer))
96
97(use-package emacs
98 :bind
99 (:map prog-mode-map
100 ("C-M-<return>" . compile)
101 ("C-<return>" . my-recompile)))
102
103(provide 'config-compile)
104;;; config-compile.el ends here