c-mode.elc 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. (defvar c-mode-syntax-table nil "Syntax table in use in C-mode buffers.")
  2. (defvar c-mode-abbrev-table nil "Abbrev table in use in C-mode buffers.")
  3. (defvar c-mode-map nil "Keymap used in C mode.")
  4. (defconst c-indent-level 2 "*Indentation of C statements with respect to containing block.")
  5. (defconst c-brace-offset 0 "*Extra indentation for braces, compared with other text in same context.")
  6. (defconst c-argdecl-indent 5 "*Indentation level of declarations of C function arguments.")
  7. (defconst c-label-offset -2 "*Offset of C label lines and case statements relative to usual indentation.")
  8. (defconst c-continued-statement-indent 2 "*Extra indent for lines not starting new statements.")
  9. (defconst c-auto-newline nil "*Non-nil means automatically newline before and after braces,
  10. and after colons and semicolons, inserted in C code.")
  11. (defun c-mode nil "\
  12. Major mode for editing C code.
  13. Expression and list commands understand all C brackets.
  14. Tab indents for C code.
  15. Meta-Control-Q indents all lines within following bracket-grouping.
  16. Comments are delimited with /* ... */.
  17. Paragraphs are separated by blank lines only.
  18. Meta-Control-H puts mark at end of C function and dot before it.
  19. Delete converts tabs to spaces as it moves back.
  20. Variables controlling indentation style:
  21. c-auto-newline
  22. Non-nil means automatically newline before and after braces,
  23. and after colons and semicolons, inserted in C code.
  24. c-indent-level
  25. Indentation of C statements within surrounding block.
  26. The surrounding block's indentation is the indentation
  27. of the line on which the open-brace appears.
  28. c-continued-statement-offset
  29. Extra indentation given to a substatement, such as the
  30. then-clause of an if or body of a while.
  31. c-brace-offset
  32. Extra indentation for line if it starts with a brace.
  33. c-argdecl-indent
  34. Indentation level of declarations of C function arguments.
  35. c-label-offset
  36. Extra indentation for line that is a label, or case or default.
  37. Turning on C mode calls the value of the variable c-mode-hook with no args,
  38. if that value is non-nil." (interactive) (byte-code "ÃˆÔ ˆ?ƒAÕ ‰ˆÖ×Ø#ˆÖÙØ#ˆÖÚÛ#ˆÖÜÝ#ˆÖÞß#ˆÖàá#ˆÖâã#ˆÖäå#‚BÈæ!ˆç‰ˆè‰ˆéÅ \"ˆ ‰ˆ?ƒ¿êë ‰ˆì!ˆíîï\"ˆíðñ\"ˆíòó\"ˆíôõ\"ˆíö÷\"ˆíøù\"ˆíúû\"ˆíüý\"ˆíþý\"ˆíÿý\"ˆí�@ý\"ˆí�Aý\"ˆí�Bý\"ˆí�C�D\")‚Ãì!ˆ�EÈ!ˆ�F P‰ˆ�EÊ!ˆ‰
  39. ˆ�EË!ˆå‰ ˆ�EÌ!ˆ�G‰ ˆ�EÍ!ˆ�H‰ ˆ�EÎ!ˆ�I‰ˆ�EÏ!ˆ�J‰ˆ�EÐ!ˆ�K‰ˆ�EÑ!ˆ‰ˆ�LÓ!…K…K�M!‡" [c-mode-map major-mode mode-name nil local-abbrev-table c-mode-abbrev-table c-mode-syntax-table i paragraph-start page-delimiter paragraph-separate indent-line-function comment-start comment-end comment-column comment-start-skip comment-indent-hook parse-sexp-ignore-comments t c-mode-hook kill-all-local-variables make-sparse-keymap define-key "{" electric-c-brace "}" ";" electric-c-semi ":" electric-c-terminator "" mark-c-function "" indent-c-exp "" backward-delete-char-untabify " " c-indent-line use-local-map c-mode "C" define-abbrev-table 0 make-syntax-table set-syntax-table modify-syntax-entry 123 "(}" 125 "){" 91 "(]" 93 ")[" 92 "\\" 47 " 14" 42 " 23" 43 " " 45 61 37 60 62 39 "\"" make-local-variable "^$\\|" "/* " " */" 32 "/\\*+ *" c-comment-indent boundp funcall] 63))
  40. (defun c-comment-indent nil (byte-code "Šn…l?ƒÁ‚ ÂÃ!ˆnƒÄÁ!‚ iT])‡" [comment-column 0 skip-chars-backward " " calculate-c-indent] 10))
  41. (defun electric-c-brace (arg) "\
  42. Insert character and correct line's indentation." (interactive "P") (byte-code "ĈÄ ?…#l…#ŠÅÆ!ˆn)†#
  43. ƒ Ç ‚!Ĉ
  44. ƒU cˆÈ !ˆ
  45. ƒ?`S‰ˆÇ ˆÈ !‚@ĈŠƒLTb‚MĈÉÊ!)‚VĈƒhŠbˆËÌ !!)‚mËÌ !!)‡" [insertpos arg c-auto-newline last-command-char nil skip-chars-backward " " newline c-indent-line delete-char -1 self-insert-command prefix-numeric-value] 28))
  46. (defun electric-c-semi (arg) "\
  47. Insert character and correct line's indentation." (interactive "P") (byte-code "ˆƒ à !‚ÄÅ !!‡" [c-auto-newline arg nil electric-c-terminator self-insert-command prefix-numeric-value] 7))
  48. (defun electric-c-terminator (arg) "\
  49. Insert character and correct line's indentation." (interactive "P") (byte-code "ňÅ`
  50. ?…4l…4ŠÇ ˆÈÉ!ˆgÊU†2Ë` \"Ì 8†1Í 8†1Î 8))?ƒi cˆÏ !ˆ…TÐ ?…T`S‰ˆÑ ˆÏ !ˆŠƒ`Tb‚aňÒÓ!)‚jňƒ|ŠbˆÔÕ
  51. !!)‚�ÔÕ
  52. !!*‡" [insertpos end arg pps last-command-char nil c-auto-newline beginning-of-line skip-chars-forward " " 35 parse-partial-sexp 3 4 5 c-indent-line c-inside-parens-p newline delete-char -1 self-insert-command prefix-numeric-value] 32))
  53. (defun c-inside-parens-p nil (byte-code "ÀÁÂ�‡" [nil (byte-code "ŠŒÀ`Á ˆ`\"ˆdbˆÂ`ÃÄ#†efÅU))‡" [narrow-to-region beginning-of-defun scan-lists -1 1 40] 8) ((error (byte-code "‡" [nil] 2)))] 5))
  54. (defun c-indent-line (&optional whole-exp) "\
  55. Indent current line as C code.
  56. Argument means shift any additional lines of grouping
  57. rigidly with thls line." (interactive "P") (byte-code "ËˆÌ ËËËd`ZÍ ˆ`‰ˆ?†$ =†$ÎÏ!ƒr =ƒkËËŠÍ ˆÐÑ!ˆgÒU‰ˆÓÔ!ˆ`‰ˆÍ ˆÐÑ!ˆÕÖ
  58. #…b…b×Ø!Tbˆi)*‰‚oÙ ‰‚ÊÐÑ!ˆ<ƒ‚@‰‚ƒËˆÎÚ!†™ÎÛ!…™ŠÜÝ!ˆÎÞ!)ƒ§Ý\\]‰‚¨ËˆgßUƒ¸Z‰‚¹ËˆgàUƒÉ \\‰‚ÊˈÐÑ!ˆiZ‰ˆá !ƒîd Z`Vƒêd Zb‚ëË‚0â `\"ˆjˆd Z`Vƒd Zb‚ˈ
  59. …0Š bˆÜÝ!ˆ`‰ˆ bˆãÝ!ˆ`‰ˆ
  60. V)…0ä
  61. Ï$-‡" [indent beg end shift-amt pos t star-start c-label-offset c-indent-level c-brace-offset whole-exp nil calculate-c-indent beginning-of-line looking-at "#" skip-chars-forward " " 42 skip-chars-backward "
  62. " re-search-forward "/\\*[ ]*" match-beginning 0 current-indentation "case[ ]" "[A-Za-z]" forward-sexp 1 ":" 125 123 zerop delete-region forward-line indent-code-rigidly] 60))
  63. (defun calculate-c-indent (&optional parse-start) "\
  64. Return appropriate indentation for current line as C code.
  65. In usual case returns an integer: the column to indent to.
  66. Returns nil if line starts inside a string, t if in a comment." (byte-code "ŠÈ ˆ`ÆÆÆ
  67. ƒ
  68. b‚É ˆ`W…3`‰ˆÊ`Ë#‰ˆ A@‰ˆ‚ˆÌ 8†=Í 8ƒFÍ 8‚à ?ƒsbˆÎÏ!ˆgÐUƒ\\Ë‚pÑ
  69. †be!ˆhÒUƒn ‚pÓ ‚àÔ fÐ\"ƒƒ Tbˆi‚àbˆÑ !ˆhÕ>?ƒ›Ö !ˆ i\\‚à bˆŠ×Ø!ˆÎÙ!ˆÚÛ!…ÏgÜUƒ¹ÝØ!‚ËÚÞ!ƒÈßàá#‚Ëßâ!ˆ‚£ˆ`W…×i)†àÓ \\,)‡" [indent-point state parse-start containing-sexp c-argdecl-indent c-continued-statement-indent nil c-indent-level beginning-of-line beginning-of-defun parse-partial-sexp 0 3 4 skip-chars-forward " " 123 c-backward-to-noncomment 41 current-indentation /= (nil 44 59 125 58 123) c-backward-to-start-of-if forward-char 1 "
  70. " looking-at "#\\|/\\*\\|case[
  71. ]\\|[a-zA-Z0-9_$]*:" 35 forward-line "/\\*" search-forward "*/" move ":"] 52))
  72. (defun c-backward-to-noncomment (lim) (byte-code "ÄÄ ?…MÅÆ
  73. \"ˆ`‰ˆ`Ç
  74. \\Y…#ŠÈÉ!ˆÊË!)ƒ.ÌÍ
  75. Î#‚IÏ ˆÐÑ!ˆÊÒ!ƒC`
  76. X‰‚I ‰ˆbˆ‚*‡" [odot stop lim t nil skip-chars-backward "
  77. " 2 forward-char -2 looking-at "\\*/" search-backward "/*" move beginning-of-line skip-chars-forward " " "#"] 19))
  78. (defun c-backward-to-start-of-if (lim) (byte-code "hÁUƒ ÂÃ!‚ ĈŠˆ`XƒTb‚ĈÆÇ!‡" [lim 41 forward-sexp -1 nil beginning-of-line skip-chars-forward " "] 7))
  79. (defun mark-c-function nil "\
  80. Put mark at end of C function, dot at beginning." (interactive) (byte-code "ÀˆÁ`!ˆÂ ˆÁ`!ˆÃ ˆÄ ‡" [nil push-mark end-of-defun beginning-of-defun backward-paragraph] 7))
  81. (defun indent-c-exp nil "\
  82. Indent each line of the C grouping following dot." (interactive) (byte-code "Áˆ CÁÁÁÁÁÁÁ`Ò
  83.  ŠÓÔ!)ˆŠ ‰ˆm?…. ?…ä
  84. ‰ ˆ ‰ ˆ ?…Km…J ‰?…È ‰ˆÕ`Ö ˆ` %‰ˆ @‰
  85. ˆ AA@…s AA@ÒYƒ€ AA@‰‚�Áˆ×Ø\"@ƒ�Ù ‚‘Áˆ×Ø \"@ƒ±×Ø\"@?ƒ©Ú ‚ªÁˆÛÔ!‚Ä×Ü \"@ƒ¿ÛÔ!‚Ä ‰ ˆ‚<ˆ
  86. ÒXƒ× ‰‚ØÁˆ ƒá ‚àÝ 
  87. \"ƒñ ‰‚òÁˆ 
  88. V…A S‰ ˆ‚óˆ 
  89. W…ÁB T‰ ˆ‚ ˆÛÔ!ˆÞß!ˆlƒ0 ‚à@…9@ÒYƒaŠà !ˆhá>?ƒXâ !ˆãä \\‰‚]@‰)‚zå@ƒm@[‚nÁ!æ‰\")ˆçè!†�çé!…�ŠÓÔ!ˆçê!)ƒ Ô\\]‰‚¡ÁˆgëUƒ³Z‰‚´ÁˆgìUƒÆ\\‰‚ÇÁˆiU†àgíU†àî`ï ˆ`\"ˆjˆ‚').
  90. ‡" [indent-stack nil restart outer-loop-done inner-loop-done state ostate this-indent last-sexp odot next-depth last-depth innerloop-done t val c-label-offset c-indent-level c-brace-offset 0 forward-sexp 1 parse-partial-sexp end-of-line nthcdr 4 c-indent-line indent-for-comment forward-line 3 /= skip-chars-forward " " c-backward-to-noncomment (nil 44 59 125 58) c-backward-to-start-of-if 2 current-indentation calculate-c-indent setcar looking-at "case[ ]" "[A-Za-z]" ":" 125 123 35 delete-region beginning-of-line] 92))