* Tab within comments in C/C++ mode
@ 2002-10-30 20:57 Chris Hobbs
2002-10-30 21:24 ` Peter Milliken
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Chris Hobbs @ 2002-10-30 20:57 UTC (permalink / raw)
I am looking for a way to allow the tab key while inside comments in C and
C++ mode. Currently, the mode will not allow a tab (let alone multiple
tabs) to be placed while in a comment. It seems to insist on formatting
the contents of the comment. Not really formatting per se, mainly just
disallowing any format I want to put in there.
Thanks for any help.
- Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Tab within comments in C/C++ mode
@ 2002-10-30 21:21 Bingham, Jay
0 siblings, 0 replies; 7+ messages in thread
From: Bingham, Jay @ 2002-10-30 21:21 UTC (permalink / raw)
In many modes the tab key is not assigned to self insert, instead it invokes a function which attempts to do formatting that is consistent with the mode. In these modes a literal tab can be inserted into the buffer with M-i or C-q TAB.
Yes, is would be nice if the folks who wrote the mode had written it so that within a comment TAB just inserted a tab character, but they did not.
-_
J_)
C_)ingham
. HP - NonStop Austin Software & Services - Software Quality Assurance
. Austin, TX
. Language is the apparel in which your thoughts parade in public.
. Never clothe them in vulgar and shoddy attire. -Dr. George W. Crane-
-----Original Message-----
From: Chris Hobbs [mailto:code_wraith@sbcglobal.net]
Sent: Wednesday, October 30, 2002 2:57 PM
To: help-gnu-emacs@gnu.org
Subject: Tab within comments in C/C++ mode
I am looking for a way to allow the tab key while inside comments in C and
C++ mode. Currently, the mode will not allow a tab (let alone multiple
tabs) to be placed while in a comment. It seems to insist on formatting
the contents of the comment. Not really formatting per se, mainly just
disallowing any format I want to put in there.
Thanks for any help.
- Chris
_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tab within comments in C/C++ mode
2002-10-30 20:57 Chris Hobbs
@ 2002-10-30 21:24 ` Peter Milliken
2002-10-30 21:34 ` Henrik Enberg
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Peter Milliken @ 2002-10-30 21:24 UTC (permalink / raw)
One way to possibly handle this is to use tmmofl to turn off cc-mode and
momentarily invoke some other mode (text mode perhaps?) when you venture
into the comments. Or you could just modify the keymapping for the TAB key?
probably other possibilities as well.
Phillip Lord has authored a package that is run as point enters and leaves
different fontification areas. So you could customise it so that as point
entered the comment area, it allowed the use of the TAB key to generate tab
characters and then changed the behaviour of Emacs back to "normal" as point
left the comment area. I use the package all of the time for similar
activities - it is a very cool idea :-)
tmmofl.el can be found at http://www.russet.org.uk/emacs.html
Peter
"Chris Hobbs" <code_wraith@sbcglobal.net> wrote in message
news:pan.2002.10.30.20.57.30.386335@sbcglobal.net...
> I am looking for a way to allow the tab key while inside comments in C and
> C++ mode. Currently, the mode will not allow a tab (let alone multiple
> tabs) to be placed while in a comment. It seems to insist on formatting
> the contents of the comment. Not really formatting per se, mainly just
> disallowing any format I want to put in there.
>
> Thanks for any help.
>
> - Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tab within comments in C/C++ mode
2002-10-30 20:57 Chris Hobbs
2002-10-30 21:24 ` Peter Milliken
@ 2002-10-30 21:34 ` Henrik Enberg
2002-10-31 1:28 ` Chris Hobbs
2002-10-31 9:32 ` P Pareit
2002-10-31 15:01 ` kgold
3 siblings, 1 reply; 7+ messages in thread
From: Henrik Enberg @ 2002-10-30 21:34 UTC (permalink / raw)
"Chris Hobbs" <code_wraith@sbcglobal.net> writes:
> I am looking for a way to allow the tab key while inside comments in C and
> C++ mode. Currently, the mode will not allow a tab (let alone multiple
> tabs) to be placed while in a comment. It seems to insist on formatting
> the contents of the comment. Not really formatting per se, mainly just
> disallowing any format I want to put in there.
`C-q TAB' should do what you want. C-q runs `quoted-insert' which
insets the next thing you type verbatim.
If you think that is annoying you could try putting this (untested) code
in ~/.emacs.el
(add-hook 'post-command-hook
(lambda ()
(when (memq major-mode '(c-mode c++-mode java-mode))
(if (eq (get-text-property (point) 'face)
'font-lock-comment-face)
(local-set-key (kbd "<tab>") 'tab-to-tab-stop)
(local-set-key (kbd "<tab>") 'c-indent-command)))))
--
Booting... /vmemacs.el
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tab within comments in C/C++ mode
2002-10-30 21:34 ` Henrik Enberg
@ 2002-10-31 1:28 ` Chris Hobbs
0 siblings, 0 replies; 7+ messages in thread
From: Chris Hobbs @ 2002-10-31 1:28 UTC (permalink / raw)
Thanks for the info guys. The "C - q" worked. I will test out the function
later on, or work out something similar. This is just the info I needed. I
had no idea c++ mode was trying a function instead of the literal. Guess I
should have checked the key bindings. :)
- Chris
On Wed, 30 Oct 2002 22:34:15 +0100, Henrik Enberg wrote:
> "Chris Hobbs" <code_wraith@sbcglobal.net> writes:
>
>> I am looking for a way to allow the tab key while inside comments in C and
>> C++ mode. Currently, the mode will not allow a tab (let alone multiple
>> tabs) to be placed while in a comment. It seems to insist on formatting
>> the contents of the comment. Not really formatting per se, mainly just
>> disallowing any format I want to put in there.
>
> `C-q TAB' should do what you want. C-q runs `quoted-insert' which
> insets the next thing you type verbatim.
>
> If you think that is annoying you could try putting this (untested) code
> in ~/.emacs.el
>
> (add-hook 'post-command-hook
> (lambda ()
> (when (memq major-mode '(c-mode c++-mode java-mode))
> (if (eq (get-text-property (point) 'face)
> 'font-lock-comment-face)
> (local-set-key (kbd "<tab>") 'tab-to-tab-stop)
> (local-set-key (kbd "<tab>") 'c-indent-command)))))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tab within comments in C/C++ mode
2002-10-30 20:57 Chris Hobbs
2002-10-30 21:24 ` Peter Milliken
2002-10-30 21:34 ` Henrik Enberg
@ 2002-10-31 9:32 ` P Pareit
2002-10-31 15:01 ` kgold
3 siblings, 0 replies; 7+ messages in thread
From: P Pareit @ 2002-10-31 9:32 UTC (permalink / raw)
Chris Hobbs wrote:
> I am looking for a way to allow the tab key while inside
> comments in C and C++ mode. Currently, the mode will not
> allow a tab (let alone multiple tabs) to be placed while
> in a comment. It seems to insist on formatting the
> contents of the comment. Not really formatting per se,
> mainly just disallowing any format I want to put in there.
>
Next to the other solutions, you might also look into:
C-h v tab-always-indent
Pieter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tab within comments in C/C++ mode
2002-10-30 20:57 Chris Hobbs
` (2 preceding siblings ...)
2002-10-31 9:32 ` P Pareit
@ 2002-10-31 15:01 ` kgold
3 siblings, 0 replies; 7+ messages in thread
From: kgold @ 2002-10-31 15:01 UTC (permalink / raw)
1 - I use this:
(global-set-key [C-tab] 'tab-to-tab-stop)
and use C-tab when I want a real tab anywhere
2 - In the mode hook:
(setq c-tab-always-indent nil)
So tab does the formatting when before text and does a tab within
text.
"Chris Hobbs" <code_wraith@sbcglobal.net> writes:
> I am looking for a way to allow the tab key while inside comments in C and
> C++ mode. Currently, the mode will not allow a tab (let alone multiple
> tabs) to be placed while in a comment. It seems to insist on formatting
> the contents of the comment. Not really formatting per se, mainly just
> disallowing any format I want to put in there.
--
--
Ken Goldman kgold@watson.ibm.com 914-784-7646
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-10-31 15:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-30 21:21 Tab within comments in C/C++ mode Bingham, Jay
-- strict thread matches above, loose matches on Subject: below --
2002-10-30 20:57 Chris Hobbs
2002-10-30 21:24 ` Peter Milliken
2002-10-30 21:34 ` Henrik Enberg
2002-10-31 1:28 ` Chris Hobbs
2002-10-31 9:32 ` P Pareit
2002-10-31 15:01 ` kgold
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.