all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* customize according to mode
@ 2005-04-04  9:35 Purnank
  2005-04-04 12:06 ` Greg Rowe
  2005-04-04 17:37 ` Alan Mackenzie
  0 siblings, 2 replies; 4+ messages in thread
From: Purnank @ 2005-04-04  9:35 UTC (permalink / raw)


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.

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.

How can i have Hungary Delete by default.

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?

Is it possible to have bookmarks in emacs.
is it possible to insert comment block by default like,
/**
 *  <cursor is here>
 *
 * @author ....
 * @file .... some file.
 * @date ... TODAY.
 * (C) some company.
 *//* ****************************** */

Thanking You.
Purnank

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: customize according to mode
  2005-04-04  9:35 customize according to mode Purnank
@ 2005-04-04 12:06 ` Greg Rowe
  2005-04-04 17:37 ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Rowe @ 2005-04-04 12:06 UTC (permalink / raw)


Purnank wrote:
> 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.

You can use hooks to make mode based customizations.  In your .emacs you 
would put something like:

(add-hook 'c-mode-hook
	(lambda ()
	(local-set-key (kbd "RET") 'c-indent-new-comment-line)))

(add-hook 'c++mode-hook
	(lambda ()
	(local-set-key (kbd "RET") 'newline-and-comment)


> 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.

http://www.emacswiki.org/cgi-bin/wiki/NoTabs


> How can i have Hungary Delete by default.

(add-hook 'c-mode-hook
	(lambda ()
	(c-toggle-hungry-state 1)))

> 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?

Try M-x delete-trailing-whitespace.  The documentations says it deletes 
all trailing whitespace across the current buffer.

> Is it possible to have bookmarks in emacs.

http://www.emacswiki.org/cgi-bin/wiki/BookMarks

> is it possible to insert comment block by default like,
> /**
>  *  <cursor is here>
>  *
>  * @author ....
>  * @file .... some file.
>  * @date ... TODAY.
>  * (C) some company.
>  *//* ****************************** */

http://doxymacs.sourceforge.net/

Hope this helps

-- 
Home is where the .bashrc is.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: customize according to mode
  2005-04-04  9:35 customize according to mode Purnank
  2005-04-04 12:06 ` Greg Rowe
@ 2005-04-04 17:37 ` Alan Mackenzie
  2005-04-04 21:56   ` Alan Mackenzie
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2005-04-04 17:37 UTC (permalink / raw)


Purnank <ghumalia.purnank@de.bosch.com> 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 bug-cc-mode@gnu.org.  ;-)

> 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: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: customize according to mode
  2005-04-04 17:37 ` Alan Mackenzie
@ 2005-04-04 21:56   ` Alan Mackenzie
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2005-04-04 21:56 UTC (permalink / raw)


Alan Mackenzie <acm@muc.de> wrote on Mon, 4 Apr 2005 17:37:43 +0000:
> Purnank <ghumalia.purnank@de.bosch.com> wrote on Mon, 4 Apr 2005 11:35:58
> +0200:

[ .... ]

> Put the following into your .emacs:

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

Apologies.  That should have been

(eval-after-load "cc-mode"
 ^^^^^ 
-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-04 21:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-04  9:35 customize according to mode Purnank
2005-04-04 12:06 ` Greg Rowe
2005-04-04 17:37 ` Alan Mackenzie
2005-04-04 21:56   ` Alan Mackenzie

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.