help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: customize according to mode


From: Alan Mackenzie
Subject: Re: customize according to mode
Date: Mon, 4 Apr 2005 17:37:43 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

Purnank <address@hidden> wrote on Mon, 4 Apr 2005 11:35:58
+0200:
> Hello all,

> I need one help.
> On my system, c-indent-new-comment-line is mapped to M-j
> But i want it to map c-indent-new-comment-line to "Return" when i am typing
> a comment and
> map "Return" to newline-and-comment when i am editing C++ file.

That's what the maintainer of CC Mode (Martin Stjernholm) wanted too.  So
he wrote the command `c-context-line-break' which does exactly that.

Put the following into your .emacs:

(after-load "cc-mode"
  '(define-key c-mode-base-map "\C-m" 'c-context-line-break))

and if it does what you want, you could always send appreciation to Martin
on address@hidden  ;-)

> Also,
> Sometimes there are tabs inserted in my file. and some time spaces.
> If i use C-j (newline-and-comment) no tabs are inserted.
> but if i use indent-region, align-entire, tabs get inserted.
> Is this the default behaviour? How can i overcome it to insert spaces
> explicitly.

That seems strange.  Are you sure it isn't just that your indents are too
small for a tab character (by default 8 columns wide)?  Emacs does indeed
use tabs for indentation by default.  You can switch this off by setting
`indent-tabs-mode' to nil, but you have to do it in _each_ buffer.  The
best way would be to put it into a hook function.  See 8 lines below!

> How can i have Hungary Delete by default.

Don't you like Budapest?  ;-)

(defun purnank-cc-mode-hook ()
  (c-toggle-hungry-state 1)
  (setq indent-tabs-mode nil))
(add-hook 'c-mode-common-hook 'purnank-cc-mode-hook)

> And,
> Is it possible to delete trailing spaces? In some other editor i used
> previously, it was possible to remove trailing spaces. The last inserted
> space can be deleted from the same. Is is possible for Emacs also?

Of course it's possible - it's Emacs!  M-x delete-trailing-whitespace.

[ .... ]

Just as a matter of interest, all these things are documented in the
manuals which are _surely_ installed on your system too.  They're not
that difficult to use, once you get used to them.  Try this:

C-h i        ; gets you into info
m cc-mode    ; gets you to the CC Mode manual.
m command and <tab><CR> ; gets you to the "command and function index"
m c-context-line-break ; gets you to the page where that function is
                       ; defined
C-s c-context-         ; finds the actual definition.

> Thanking You.

All the best to yourself, too!

> Purnank

-- 
Alan Mackenzie (Munich, Germany)
Email: address@hidden; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

[Prev in Thread] Current Thread [Next in Thread]