From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: david@adboyd.com (J. David Boyd) Newsgroups: gmane.emacs.help 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 Message-ID: <873ayhyktt.fsf@adboyd.com> References: <1187377332.321751.12480@50g2000hsm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1187382071 7962 80.91.229.12 (17 Aug 2007 20:21:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2007 20:21:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 17 22:21:06 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IM8Jd-0007EX-DX for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Aug 2007 22:21:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IM8Jc-0000YD-Rw for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Aug 2007 16:21:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IM8JN-0000WK-4y for help-gnu-emacs@gnu.org; Fri, 17 Aug 2007 16:20:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IM8JM-0000Vk-KN for help-gnu-emacs@gnu.org; Fri, 17 Aug 2007 16:20:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IM8JM-0000Vd-HX for help-gnu-emacs@gnu.org; Fri, 17 Aug 2007 16:20:48 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IM8JL-0001Lt-Uo for help-gnu-emacs@gnu.org; Fri, 17 Aug 2007 16:20:48 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IM8JD-0007Rn-NL for help-gnu-emacs@gnu.org; Fri, 17 Aug 2007 22:20:39 +0200 Original-Received: from 156-40.126-70.tampabay.res.rr.com ([70.126.40.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Aug 2007 22:20:39 +0200 Original-Received: from david by 156-40.126-70.tampabay.res.rr.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Aug 2007 22:20:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 59 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 156-40.126-70.tampabay.res.rr.com User-Agent: Gnus/5.1100000000000003 (Gnus v5.11) Emacs/22.1 (cygwin) Cancel-Lock: sha1:Jk9o/mTdNen0Tf6wfrFnvZ+6g7s= X-Detected-Kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46661 Archived-At: "Leo.Hou" 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.