Emacs starts in c++ mode but doesn't use c++ setup


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Emacs starts in c++ mode but doesn't use c++ setup
# 1  
Old 04-09-2011
Emacs starts in c++ mode but doesn't use c++ setup

Hi,

I'm trying to use Emacs to edit C++ files (extension .cpp). My ~/.emacs file contains:
Code:
(defun my-c++-indent-setup ()
  (setq c-basic-offset 4)
  (setq c-default-style "linux")
)
(add-hook 'c++-mode-hook 'my-c++-indent-setup)

When I open a C++ file in Emacs, it's in C++ mode (the syntax coloring is correct). But indenting braces is done like this:
Code:
if (1)
    {

When I manually enter M-x c++-mode, suddenly the braces are how I want them:
Code:
if (1)
{

If I'm already in c++ mode, why does indentation work properly only after entering c++ mode again? Is my hook not right? Thanks in advance.
# 2  
Old 04-11-2011
CC Mode Manual

Make sure you have the latest release of CC EMACS. Maybe sourceforge has example files. Not that I am an emacs guy! I have been resisting since MULTICS 25 years ago -- not there so often, install not always welcome.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. HP-UX

From a C++ application how to find if a hpux host is in standard mode or trusted mode

is there a way for my C++ application to find out which mode the hpux OS is running in? standard mode or trusted mode. (3 Replies)
Discussion started by: einsteinBrain
3 Replies

2. Shell Programming and Scripting

Need to write a shell script that starts one, then kills it, then starts another?

This is on a CentOS box, I have two scripts that need to run in order. I want to write a shell script that calls the first script, lets it run and then terminates it after a certain number of hours (that I specify of course), and then calls the second script (they can't run simultaneously) which... (3 Replies)
Discussion started by: btramer
3 Replies

3. UNIX for Dummies Questions & Answers

How to use emacs? Also how to open existing emacs files with .cgi format?

Hi All, I am new to this forum and a beginner in unix. Please correct me if I put the question in a wrong way.. How to use emacs editor? Also how to open existing emacs files with .cgi format? I have the following link :- http link i.e. url and path : /abc/xyz.dev/xyz/documents What... (7 Replies)
Discussion started by: swathi123
7 Replies

4. UNIX for Dummies Questions & Answers

tar xzCf --mode doesn't work.

$ touch x y $ ls -l x y -rw-r--r-- 1 g660 0 Sep 26 03:38 x -rw-r--r-- 1 g660 0 Sep 26 03:38 y $ chmod 777 x y $ ls -l x y -rwxrwxrwx 1 g660 0 Sep 26 03:38 x -rwxrwxrwx 1 g660 0 Sep 26 03:38 y $ rm a.tar $ tar cvzf a.tar.gz . ./ ./x ./y ./a.tar.gz $ ls -l total 4 -rw-r--r-- 1 ... (3 Replies)
Discussion started by: volbod
3 Replies

5. UNIX and Linux Applications

Commenting out block of code in emacs in python mode

Hi, I am not sure if this is the right forum to post an emacs question, but if you could point me to an appropriate emacs forum that would be useful too. Anyway, here is the description of the problem: I usually develop python code with emacs, emacs being in python code. On my desktop a... (0 Replies)
Discussion started by: alex57326
0 Replies

6. AIX

NIM server setup on etherchannel setup environment

I know that IBM's official stance is that NIM does not work on etherchannel environment, but has anyone able to get around it? I'm working on a p5-590 LPAR system, and the NIM master and clients are all on the same frame. Any help is appreciated. (1 Reply)
Discussion started by: pdtak
1 Replies

7. UNIX for Dummies Questions & Answers

emacs in text mode how to?

hello all I saw somewhere there is some kind of version of emacs in full text mode ? how can I get/download it? if I have ordenry emacs installed can I start it in text mode? thanks (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question