* cc-mode: Is there a method automatically insert space between "if", "()" and "{"
@ 2009-09-06 10:45 Wang Lei
0 siblings, 0 replies; only message in thread
From: Wang Lei @ 2009-09-06 10:45 UTC (permalink / raw
To: help-gnu-emacs@gnu.org
Hi, all!
If the subject is not clear enough, sorry.
Could someone tell me how to insert spaces automatically as you type
in the following situation.
if () { <---here, between if, (), {
}
while () { <--- here
}
for () { <---here
}
But not insert in function call.
And, Could you let me see your setting about c-mode? Today, after
times' trying finally I can achieve this.
int a[] = {
{},
{}
};
I'm tired. Any help is appreciated. At the end, this is mine.
-------code----------------------
;; Smart compile
(require 'smart-compile+)
(add-to-list 'smart-compile-alist '("\\.c$" . "gcc -O2 %f -o %n"))
(global-set-key [?\C-c ?\C-c] 'smart-compile)
(global-set-key [?\C-c ?\C-r] 'smart-run)
;;C mode
(add-to-list 'auto-mode-alist '("\\.[ch]$" . my-c-mode))
(setq c-eldoc-includes "`pkg-config gtk+-2.0 --cflags` -I./ -I../ -I../lib/")
(defun my-c-mode ()
(require 'c-eldoc)
(require 'ctypes)
(c-mode)
(c-turn-on-eldoc-mode)
(c-set-style "linux")
(setq c-hanging-braces-alist
'((brace-list-open after)
(brace-list-intro)
(brace-entry-open before)
(brace-entry-close after)
(brace-list-close after)
(substatement-open after)
(block-close . c-snug-do-while)
(arglist-cont-nonempty)))
(setq c-cleanup-list
'(comment-close-slash
list-close-comma
defun-close-semi
brace-else-brace
brace-elseif-brace))
(setq c-auto-newline t)
(setq c-hungry-delete-key t)
(setq indent-tabs-mode t)
(setq compilation-ask-about-save nil)
(local-unset-key [?\C-c ?\C-c])
(define-key c-mode-base-map [return] 'newline-and-indent))
--------code--------------------------------
--
Regards
Lei
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-06 10:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-06 10:45 cc-mode: Is there a method automatically insert space between "if", "()" and "{" Wang Lei
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.