commit 9a3867c4728a7ea5db886714cbfd675936c6fed6
parent 38d4ee9662755168c1712eecf21296d666a4d394
Author: Michael Neuper <michael@michaelneuper.com>
Date: Tue, 5 Aug 2025 21:44:15 +0200
customise cc-mode
- enable editorconfig package
- use k&r style
- change default compile command
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/config.org b/config.org
@@ -829,11 +829,21 @@ Improve =eglot= performance.
#+end_src
** :lang
*** cc
-Set indentation level for =cc-mode= to 2 and fix issue where two new lines are inserted after ={=.
+Configure =cc-mode=.
#+begin_src emacs-lisp
(after! cc-mode
+ (setf (alist-get 'c-mode c-default-style) "k&r")
(setq c-basic-offset 2))
+(add-hook 'c-mode-hook
+ (lambda ()
+ (unless (or (file-exists-p "makefile")
+ (file-exists-p "Makefile"))
+ (setq-local compile-command "cc -Wall -o main main.c"))))
+#+end_src
+
+ Fix issue where two new lines are inserted after ={=.
+#+begin_src emacs-lisp
(after! eglot
(add-hook! 'eglot-managed-mode-hook :append
(defun +eglot--rm-eglot--post-self-insert-hook ()
diff --git a/init.el b/init.el
@@ -79,7 +79,7 @@
debugger ; FIXME stepping through code, to help you add bugs
;;direnv
;;docker
- ;;editorconfig ; let someone else argue about tabs vs spaces
+ editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation