Update cc-mode

This commit is contained in:
Marcus Kammer 2024-02-05 14:40:28 +01:00
parent 75eb5f9286
commit b55c1c77ab

View file

@ -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