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

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

Re: Tab within comments in C/C++ mode


From: Chris Hobbs
Subject: Re: Tab within comments in C/C++ mode
Date: Thu, 31 Oct 2002 01:28:23 GMT
User-agent: Pan/0.13.0 (The whole remains beautiful)

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



reply via email to

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