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

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

Re: comment / uncomment region


From: exits funnel
Subject: Re: comment / uncomment region
Date: Sun, 1 Aug 2004 19:33:55 -0700 (PDT)

--- Pascal Bourguignon
<address@hidden> wrote:

> exits funnel <address@hidden> writes:
> 
> > Hello,
> > 
> > I'm having trouble getting comment-region and
> > uncomment-region to work in the .grammar files I'm
> > editing.  I'm pretty new to Emacs but I understnad
> > they don't work because there is no major mode for
> > these sablecc grammar files.  I've looked at the
> doc a
> > bit and I understand that I have to set the
> variable
> > comment-start to "//" but when I evaluate (setq
> > comment-start) in the scratch buffer it seems to
> > change the value only for that buffer.  Can anyone
> > give me a jump start here?  Ideally, I'd like to
> be
> > able to put something in my .emacs file which will
> set
> > its value for any active .grammar file, but I'd be
> > satisfied if I could at least figure out how to
> set it
> > interactively for the current buffer.  Thanks in
> > advance.
> 
> Yes, that's because comment-start is a buffer-local
> variable.
> You have to set it in your grammar buffer.
> 
> You can do it manually with:
> 
>     M-x eval-expression RET (setq comment-start
> "//") RET
> 
> or rather:
> 
>     M-x set-variable    RET comment-start RET "//"
> RET
> 
> 
> You could put this at the end of each of your
> grammar files:
> 
> // Local Variables:
> // comment-start: "//"
> // End:
> 
> 
> Or, if you don't want to program a mode for your
> grammar files you
> could have a find-file-hook that would check the
> file type (or file
> name extension) and would initialize the buffer
> environment when it
> finds that a grammar is being opened. Something
> like:
> 
> (add-hook 'find-file-hook
>      (lambda () 
>         (when (string-match "\\.grammar$"
> (buffer-file-name))
>            (setf comment-start "//")
>            ;; ...
>            )))

Thanks, Pascal, that is exactly what I was looking
for.

-exits
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
> 



                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 




reply via email to

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