From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Leo.Hou" 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 23:20:28 -0000 Organization: http://groups.google.com Message-ID: <1187392828.827057.66510@w3g2000hsg.googlegroups.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 1187394041 9858 80.91.229.12 (17 Aug 2007 23:40:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Aug 2007 23:40:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 18 01:40:39 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 1IMBQj-0001uA-FD for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Aug 2007 01:40:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IMBQj-0000Nx-0l for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Aug 2007 19:40:37 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!postnews.google.com!w3g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Followup-To: gnu.emacs.help Original-Lines: 62 Original-NNTP-Posting-Host: 206.132.194.9 Original-X-Trace: posting.google.com 1187392829 18193 127.0.0.1 (17 Aug 2007 23:20:29 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 17 Aug 2007 23:20:29 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: w3g2000hsg.googlegroups.com; posting-host=206.132.194.9; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:151098 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:46671 Archived-At: On Aug 17, 1:20 pm, da...@adboyd.com (J. David Boyd) wrote: > "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.- Hide quoted text - > > - Show quoted text - Thanks David! I tried it and I loved it except for one thing: I need to M-x hide-ifdefs every time I open a new file. Can i add some hooks or something like that to keep it on forever?