From: Wang Lei <wanglei.198112@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: cc-mode: Is there a method automatically insert space between "if", "()" and "{"
Date: Sun, 6 Sep 2009 18:45:11 +0800 [thread overview]
Message-ID: <a0a0cf140909060345k76fc9c8ag5b7bfc6cb732b983@mail.gmail.com> (raw)
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
reply other threads:[~2009-09-06 10:45 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0a0cf140909060345k76fc9c8ag5b7bfc6cb732b983@mail.gmail.com \
--to=wanglei.198112@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.