Emacs personal configuration
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

48 Zeilen
1.4KB

  1. ;;; package --- C mode
  2. ;;; Commentary:
  3. ;;; Code:
  4. ;;https://www.emacswiki.org/emacs/IndentingC
  5. ;;(require-package 'guess-offset)
  6. ;; (setq c-default-style "linux"
  7. ;; c-basic-offset 4
  8. ;; tab-width 4
  9. ;; indent-tabs-mode t)
  10. ;; http://www.linuxfromscratch.org/alfs/view/hacker/part2/hacker/coding-style.html
  11. (defun linux-c-mode ()
  12. "C mode with adjusted defaults for use with the Linux kernel."
  13. (interactive)
  14. (c-mode)
  15. (c-set-style "K&R")
  16. (setq c-basic-offset 4
  17. tab-width 4
  18. indent-tabs-mode t)
  19. (quagga-linux-style)
  20. )
  21. (setq auto-mode-alist
  22. (cons '("\\.[ch]$" . linux-c-mode)
  23. auto-mode-alist))
  24. ;;http://www.delorie.com/gnu/docs/emacs/cc-mode_6.html
  25. ;;http://www.gnu.org/software/emacs/manual/html_mono/ccmode.html#Minor-Modes
  26. ;; C-c C-a: (add-hook 'c-mode-common-hook '(lambda () (c-toggle-auto-state 1)))
  27. ;; For Quagga
  28. ;; https://www.emacswiki.org/emacs/IndentingC#toc11
  29. (defun quagga-linux-style ()
  30. (when (and buffer-file-name
  31. (string-match "quagga" buffer-file-name))
  32. (c-set-style "gnu")
  33. (dtrt-indent-undo)
  34. (setq c-basic-offset 2
  35. tab-width 8
  36. indent-tabs-mode nil)))
  37. ;; Compile key binding
  38. ;; http://tuhdo.github.io/c-ide.html#orgheadline57
  39. (global-set-key (kbd "<f5>") (lambda ()
  40. (interactive)
  41. (setq-local compilation-read-command nil)
  42. (call-interactively 'compile)))
  43. (provide 'init-c)