/contrib/cvs/cvs-format.el

https://bitbucket.org/freebsd/freebsd-head/ · Lisp · 93 lines · 7 code · 19 blank · 67 comment · 0 complexity · 6b17d859053989353aa1a293189bf9aa MD5 · raw file

  1. ;; -*- lisp-interaction -*-
  2. ;; -*- emacs-lisp -*-
  3. ;;
  4. ;; Set emacs up for editing code using CVS indentation conventions.
  5. ;; See HACKING for more on what those conventions are.
  6. ;; To use, put in your .emacs:
  7. ;; (load "c-mode")
  8. ;; (load "cvs-format.el")
  9. ;; You need to load c-mode first or else when c-mode autoloads it will
  10. ;; clobber the settings from cvs-format.el. Using c-mode-hook perhaps would
  11. ;; be a cleaner way to handle that. Or see below about (set-c-style "BSD").
  12. ;;
  13. ;; Credits: Originally from the personal .emacs file of Rich Pixley,
  14. ;; then rich@cygnus.com, circa 1992. He sez "feel free to copy."
  15. ;;
  16. ;;
  17. ;;
  18. ;; This section sets constants used by c-mode for formating
  19. ;;
  20. ;;
  21. ;; If `c-auto-newline' is non-`nil', newlines are inserted both
  22. ;;before and after braces that you insert, and after colons and semicolons.
  23. ;;Correct C indentation is done on all the lines that are made this way.
  24. (setq c-auto-newline nil)
  25. ;;*Non-nil means TAB in C mode should always reindent the current line,
  26. ;;regardless of where in the line point is when the TAB command is used.
  27. ;;It might be desirable to set this to nil for CVS, since unlike GNU
  28. ;; CVS often uses comments over to the right separated by TABs.
  29. ;; Depends some on whether you're in the habit of using TAB to
  30. ;; reindent.
  31. ;(setq c-tab-always-indent nil)
  32. ;;; It seems to me that
  33. ;;; `M-x set-c-style BSD RET'
  34. ;;; or
  35. ;;; (set-c-style "BSD")
  36. ;;; takes care of the indentation parameters correctly.
  37. ;; C does not have anything analogous to particular function names for which
  38. ;;special forms of indentation are desirable. However, it has a different
  39. ;;need for customization facilities: many different styles of C indentation
  40. ;;are in common use.
  41. ;;
  42. ;; There are six variables you can set to control the style that Emacs C
  43. ;;mode will use.
  44. ;;
  45. ;;`c-indent-level'
  46. ;; Indentation of C statements within surrounding block. The surrounding
  47. ;; block's indentation is the indentation of the line on which the
  48. ;; open-brace appears.
  49. (setq c-indent-level 4)
  50. ;;`c-continued-statement-offset'
  51. ;; Extra indentation given to a substatement, such as the then-clause of
  52. ;; an if or body of a while.
  53. (setq c-continued-statement-offset 4)
  54. ;;`c-brace-offset'
  55. ;; Extra indentation for line if it starts with an open brace.
  56. (setq c-brace-offset -4)
  57. ;;`c-brace-imaginary-offset'
  58. ;; An open brace following other text is treated as if it were this far
  59. ;; to the right of the start of its line.
  60. (setq c-brace-imaginary-offset 0)
  61. ;;`c-argdecl-indent'
  62. ;; Indentation level of declarations of C function arguments.
  63. (setq c-argdecl-indent 4)
  64. ;;`c-label-offset'
  65. ;; Extra indentation for line that is a label, or case or default.
  66. ;; This doesn't quite do the right thing for CVS switches, which use the
  67. ;; switch (foo)
  68. ;; {
  69. ;; case 0:
  70. ;; break;
  71. ;; style. But if one manually aligns the first case, then the rest
  72. ;; should work OK.
  73. (setq c-label-offset -4)
  74. ;;;; eof