Difference between revisions of "Template:NewPage"

From WikEmacs
Jump to navigation Jump to search
Line 1: Line 1:
'''{{{1}}}''' is a wonderful mode which does wonderful things.
+
'''c-mode''' is the default [[major mode]] for editing [[C]] source files
 +
({{File|.c}} and {{File|.h}} files). It uses {{ModeLink|cc-mode}}.
  
 
<!-----DONT REMOVE ANYTHING FROM THIS TEMPLATE ------------------------------>
 
<!-----DONT REMOVE ANYTHING FROM THIS TEMPLATE ------------------------------>
Line 12: Line 13:
 
= Basic setup =
 
= Basic setup =
  
Install these third party libraries or read this section before proceeding.
+
c-mode is bundled with Emacs by default. No additional setup is required.  
  
 
= Helpful keybindings =
 
= Helpful keybindings =
  
; {{Keys|C-x C-c}}
+
; {{Keys|C-M-a}}
: Quit Emacs.
+
: Go to the beginning of the current function. If you are between 2 functions, go the start of the previous one.
  
; {{CommandKeys|C-x C-s|save-buffer}}
+
; {{Keys|C-M-e}}
: Save buffer.
+
: Go to the end of the current function. If you are between 2 functions, go to the end of the next one.  
  
 
<!------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------->
Line 26: Line 27:
 
<!-- Customization common to all platforms goes here -->
 
<!-- Customization common to all platforms goes here -->
  
== Customization 1 ==
+
== Change default indenting style ==
 
<source lang="lisp">
 
<source lang="lisp">
(message "This stuff will go in your .emacs")
+
; set k&r style
 +
(setq c-set-style "k&r")
 +
; indent with 4 spaces
 +
(setq c-basic-offset 4)
 
</source>
 
</source>
  
Line 63: Line 67:
 
= [[Emacs-23]] =
 
= [[Emacs-23]] =
 
<!-- Customization/Notes specific to Emacs-22 -->
 
<!-- Customization/Notes specific to Emacs-22 -->
Emacs-23 is not as great as Emacs-24. You will have these problems and you can workaround it this way.
+
 
  
 
<!------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------->
Line 69: Line 73:
 
= Recommended Reading =
 
= Recommended Reading =
 
<!-- Only internal links. DO NOT insert EXTERNAL LINKS -->
 
<!-- Only internal links. DO NOT insert EXTERNAL LINKS -->
* [[Internal Link1]]
 
* [[Internal Link2]]
 
  
 
<!------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------->
  
 
= Project Pages =
 
= Project Pages =
* [http://bazaar.canonical.com/en/ Bazaar]
+
* [http://cc-mode.sourceforge.net/ cc-mode]
* [http://doc.bazaar-vcs.org/bzr.dev/en/user-guide/index.html Bzr Users Guide]
 
  
 
<!------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------->
  
 
= Tutorial Pages =
 
= Tutorial Pages =
;[http://wiki.bazaar.canonical.com/EmacsTips Emacs as commit message editor]   
+
<!-- ;[http://wiki.bazaar.canonical.com/EmacsTips Emacs as commit message editor]  -->
:Tips for setting up Emacs as Bazaar commit editor.
+
<!-- :Tips for setting up Emacs as Bazaar commit editor. -->
  
 
<!------------------------------------------------------------------------->
 
<!------------------------------------------------------------------------->
 
<!-- Add categories based on user-level (beginner etc), user-role (programming, emacs contributor etc), platform (windows, linux etc) or work flow (text editing, document authoring etc)  -->
 
<!-- Add categories based on user-level (beginner etc), user-role (programming, emacs contributor etc), platform (windows, linux etc) or work flow (text editing, document authoring etc)  -->
  
[[Category:TestCategory1]][[Category:TestCategory2]]
+
[[Category:Programming]]

Revision as of 11:10, 31 March 2012

c-mode is the default major mode for editing C source files (.c and .h files). It uses cc-mode.



Basic setup

c-mode is bundled with Emacs by default. No additional setup is required.

Helpful keybindings

[C-M-a]
Go to the beginning of the current function. If you are between 2 functions, go the start of the previous one.
[C-M-e]
Go to the end of the current function. If you are between 2 functions, go to the end of the next one.

Common Customization

Change default indenting style

; set k&r style
(setq c-set-style "k&r")
; indent with 4 spaces
(setq c-basic-offset 4)


GNU/Linux

OS X

Windows

Emacs-24

Emacs-23

Recommended Reading

Project Pages


Tutorial Pages