unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: david@adboyd.com (J. David Boyd)
To: help-gnu-emacs@gnu.org
Subject: Re: VIM can recognize #if 0 #endif as comment pair, how to do that in Emacs?
Date: Fri, 17 Aug 2007 16:20:30 -0400	[thread overview]
Message-ID: <873ayhyktt.fsf@adboyd.com> (raw)
In-Reply-To: 1187377332.321751.12480@50g2000hsm.googlegroups.com

"Leo.Hou" <leo.hou@gmail.com> writes:

> Hi Experts,
>
>
> I saw a friend using VIM and it recognizes #if 0 -- #endif as comment
> pair and use the comment color for the code in between!
>
> This is so cool because I had a big headache using emacs+etags jumping
> into others' code, spent 5 minutes and then realized that emacs
> brought me to some codes between a #if0 -- #endif pair. :'-(
>
> Can anyone make Emacs to recognize this common convention and
> highlight all the pieces between them as comment?
>
>
>
> Thanks!
>
> Leo

Not _exactly_ what you are talking about, but I like this:

>From C-h f hide-ifdef-mode

hide-ifdef-mode is an interactive autoloaded Lisp function in `hideif'.
(hide-ifdef-mode &optional arg)

Toggle Hide-Ifdef mode.  This is a minor mode, albeit a large one.
With arg, turn Hide-Ifdef mode on if arg is positive, off otherwise.
In Hide-Ifdef mode, code within #ifdef constructs that the C preprocessor
would eliminate may be hidden from view.  Several variables affect
how the hiding is done:

`hide-ifdef-env'
	An association list of defined and undefined symbols for the
	current buffer.  Initially, the global value of `hide-ifdef-env'
	is used.

`hide-ifdef-define-alist'
	An association list of defined symbol lists.
        Use `hide-ifdef-set-define-alist' to save the current `hide-ifdef-env'
        and `hide-ifdef-use-define-alist' to set the current `hide-ifdef-env'
        from one of the lists in `hide-ifdef-define-alist'.

`hide-ifdef-lines'
	Set to non-nil to not show #if, #ifdef, #ifndef, #else, and
	#endif lines when hiding.

`hide-ifdef-initially'
	Indicates whether `hide-ifdefs' should be called when Hide-Ifdef mode
	is activated.

`hide-ifdef-read-only'
	Set to non-nil if you want to make buffers read only while hiding.
	After `show-ifdefs', read-only status is restored to previous value.


Uses keymap "hide-ifdef-mode-map", which is not currently defined.

  reply	other threads:[~2007-08-17 20:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 19:02 VIM can recognize #if 0 #endif as comment pair, how to do that in Emacs? Leo.Hou
2007-08-17 20:20 ` J. David Boyd [this message]
     [not found] ` <mailman.4927.1187382051.32220.help-gnu-emacs@gnu.org>
2007-08-17 23:20   ` Leo.Hou
2007-08-20 14:33     ` J. David Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873ayhyktt.fsf@adboyd.com \
    --to=david@adboyd.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).