From 14d3f589288b6ad80a159d43b2ae863c6e33c804 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 25 Jun 2024 12:56:12 +0100 Subject: (Emacs/config)~Rework clang-format a bit Use before-save-hook rather than after-save-hook, which solves the double save issue. --- Emacs/.config/emacs/config.org | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Emacs/.config') diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org index d550aac..848e9a1 100644 --- a/Emacs/.config/emacs/config.org +++ b/Emacs/.config/emacs/config.org @@ -3175,10 +3175,13 @@ Tons of stuff, namely: (statement-cont . +))))) #+end_src *** Clang format -Clang format comes inbuilt with clang, so download that before using -this. Formats C/C++ files depending on a format (checkout the Clang -format [[file:~/Dotfiles/ClangFormat/.clang-format][config file]] in -my dotfiles). +clang-format is a program that formats C/C++ files. It's highly +configurable and quite fast. I have a root configuration in my +Dotfiles (check it out +[[file:~/Dotfiles/ClangFormat/).clang-format][here]]. + +Clang format comes inbuilt with clang/LLVM, so it's quite likely to be +on your machine. #+begin_src emacs-lisp (use-package clang-format @@ -3198,8 +3201,8 @@ my dotfiles). (let ((save-func (proc (interactive) (clang-format-buffer)))) (if clang-format-mode - (add-hook 'after-save-hook save-func nil t) - (remove-hook 'after-save-hook save-func t)))) + (add-hook 'before-save-hook save-func nil t) + (remove-hook 'before-save-hook save-func t)))) (defun +code/clang-format-region-or-buffer () (interactive) (if (mark) -- cgit v1.2.3-13-gbd6f