Initial commit for v1.0 of Simply Emacs.

This commit is contained in:
2026-07-24 09:47:24 +02:00
commit 7774e58c79
13 changed files with 1244 additions and 0 deletions
+71
View File
@@ -0,0 +1,71 @@
;;; init-build.el --- Project build command -*- lexical-binding: t; -*-
;;; Commentary:
;; Build via built-in `compile', running ./build.sh from the project root.
;; compile saves buffers, reuses one output buffer, and turns file:line:col
;; into clickable jumps — a thin wrapper, not a terminal-send hack.
;;; Code:
;; Always show *compilation* as a fixed right-hand panel, so the toggle below
;; hits a predictable window.
(add-to-list 'display-buffer-alist
'("\\*compilation\\*"
(display-buffer-reuse-window display-buffer-in-side-window)
(side . right)
(window-width . 0.35)))
;; If t is too aggressive (e.g. auto-scrolls while trying to read mid-output
;; that hasn't errored yet), swap to:
;; (setq compilation-scroll-output 'first-error)
(setq compilation-scroll-output t)
(defun my/project-build (&optional args)
"Run ./build.sh from the project root, appending ARGS (a string) if given.
Errors if build.sh isn't readable there. Saves all buffers first."
(let* ((root (if (project-current)
(project-root (project-current))
default-directory))
(script (expand-file-name "build.sh" root))
(default-directory root))
(unless (file-readable-p script)
(user-error "No build.sh found in %s" root))
(save-some-buffers t)
(compile (string-trim (concat "./build.sh " (or args ""))))))
(defun my/build ()
"Build the current project via `./build.sh' with no arguments."
(interactive)
(my/project-build nil))
(defun my/build-with-options ()
"Build the current project, prompting for arguments to append."
(interactive)
(my/project-build (read-string "build.sh args: ")))
(defun my/toggle-build-panel ()
"Show/hide the *compilation* window from the last run (doesn't rebuild)."
(interactive)
(let ((buf (get-buffer "*compilation*")))
(cond
((null buf)
(user-error "No build output yet — run `my/build' first"))
((get-buffer-window buf)
(delete-window (get-buffer-window buf)))
(t
(display-buffer buf)))))
;; Global (not evil-scoped) so it works from any state or buffer.
;; C-c C-c build C-c C-o build w/ options C-j toggle panel
(global-set-key (kbd "C-c C-c") #'my/build)
(global-set-key (kbd "C-c C-o") #'my/build-with-options)
(global-set-key (kbd "C-j") #'my/toggle-build-panel)
(with-eval-after-load 'which-key
(which-key-add-key-based-replacements
"C-c" "code"
"C-c c" "build"
"C-c o" "build (with options)"))
(provide 'init-build)
;;; init-build.el ends here