From b55c1c77ab50fbc97a1d4ac8fb295f569dec276b Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Mon, 5 Feb 2024 14:40:28 +0100 Subject: [PATCH] Update cc-mode --- bundle/bundle--package.el | 43 +++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/bundle/bundle--package.el b/bundle/bundle--package.el index 4ae100d6..fbbba1e0 100644 --- a/bundle/bundle--package.el +++ b/bundle/bundle--package.el @@ -54,38 +54,41 @@ (setq sql-mariadb-options '("-C" "-t" "-f" "-n")) (setq sql-mysql-options '("-C" "-t" "-f" "-n")))) -;; (use-package cc-mode -;; :defer t -;; ;; https://www.gnu.org/prep/standards/html_node/Writing-C.html -;; :ensure nil -;; ;; :hook (c-mode . eglot-ensure) -;; :hook (c-mode-common . c-toggle-auto-newline) -;; :custom -;; (fill-column 79) ; according to gnu style guide -;; (c-basic-offset 2) ; "" -;; :config -;; (defun me/c-mode-style-hook () -;; ;; if linux kernel source use linux style, else use gnu style -;; (c-set-style -;; (if (and (buffer-file-name) -;; (string-match "/usr/src/linux" (buffer-file-name))) -;; "linux" -;; "gnu"))) -;; (add-hook 'c-mode-common-hook 'me/c-mode-style-hook)) +(use-package cc-mode + :defer t + :ensure nil + :hook (c-mode-common . c-toggle-auto-newline) + :custom + (fill-column 79) + (c-basic-offset 2)) + +(defun me/c-mode-style-hook () + ;; https://www.gnu.org/prep/standards/html_node/Writing-C.html + ;; if linux kernel source use linux style, else use gnu style + (c-set-style + (if (and (buffer-file-name) + (string-match "/usr/src/linux" (buffer-file-name))) + "linux" + "gnu"))) + +(add-hook 'c-mode-common-hook 'me/c-mode-style-hook) ;; (defun me/c-mode-compile-command-hook () ;; ;; if no makefile use gcc for compile command ;; (unless (or (file-exists-p "makefile") -;; (file-exists-p "Makefile")) +;; (file-exists-p "Makefile")) ;; (set (make-local-variable 'compile-command) ;; (concat "gcc " "-Wall " "-g " buffer-file-name " -o " ;; (file-name-sans-extension buffer-file-name))))) + ;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-command-hook) + ;; (defun me/c-mode-compile-on-save () ;; ;; compile on save hook ;; (make-local-variable 'after-save-hook) ;; (add-hook 'after-save-hook (lambda () (compile compile-command)))) -;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-on-save)) + +;; (add-hook 'c-mode-common-hook 'me/c-mode-compile-on-save) ;; (use-package js-mode ;; :ensure nil