cc-mode

Make Emacs less aggressive about indentation

╄→尐↘猪︶ㄣ 提交于 2019-12-18 17:14:27
问题 Emacs reindents the current line whenever I type certain things, like ";" or "//". This is pretty annoying, since there are a whole lot of places where it isn't smart enough to indent correctly. How do I disable this feature? I still want to be able to indent the line with TAB, but I don't want any source code I type to cause it to reindent. (I'm using Dylan Moonfire's C# mode, but this probably applies to any cc-mode.) 回答1: Try running c-toggle-electric-state to turn off the electric action

c++-mode-hook and c-mode-hook appears to run twice

﹥>﹥吖頭↗ 提交于 2019-12-14 02:46:08
问题 I use this command to start emacs $ emacs -Q c-mode-test.el then I use C-xC-e to eval every line (require 'cc-mode) (add-hook 'c-mode-common-hook '(lambda () (print "hello"))) (add-hook 'c-mode-hook '(lambda () (print "hello c"))) (c-mode) after this, the minibuffer shows "hello" "hello c" "hello c" nil and c++-mode-hook run just the same (add-hook 'c++-mode-hook '(lambda () (print "hello c++"))) (c++-mode) the minibuffer "hello" "hello c++" "hello c++" nil why it run twice or something wrong

How can can I get emacs to insert closing braces automatically

白昼怎懂夜的黑 提交于 2019-12-10 13:34:25
问题 I've just started using emacs, and there's one feature I'd really like, and searching around a bit was fruitless. I hope someone else has done this because I don't want to learn elisp just yet. void foo()<cursor> I would like typing an "{" to cause this to happen void foo(){ <cursor> } I would like this to only happen in cc-mode, and only at the end of a line when not in a string/comment/etc The first thing that came to mind was rebinding "{" to do this always(I could figure out how to do

Make Emacs less aggressive about indentation

独自空忆成欢 提交于 2019-11-30 15:26:34
Emacs reindents the current line whenever I type certain things, like ";" or "//". This is pretty annoying, since there are a whole lot of places where it isn't smart enough to indent correctly. How do I disable this feature? I still want to be able to indent the line with TAB, but I don't want any source code I type to cause it to reindent. (I'm using Dylan Moonfire's C# mode, but this probably applies to any cc-mode.) Try running c-toggle-electric-state to turn off the electric action of these characters. You can do this as part of a c-mode-common-hook, or toggle the state manually by