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

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

hs-hide-level doesn't hide multiline comments in C mode


From: Britton Kerin
Subject: hs-hide-level doesn't hide multiline comments in C mode
Date: Thu, 22 Jan 2004 12:48:54 -0900 (AKST)

The info node for hs-minor-mode (Hideshow minor mode) has second 
paragraph:

       Just what constitutes a block depends on the major mode.  In C mode
    or C++ mode, they are delimited by braces, while in Lisp mode and
    similar modes they are delimited by parentheses.  Multi-line comments
    also count as blocks.

But hs-hide-level doesn't seem to treat multi-line comments as blocks, 
even when hs-hide-comments-when-hiding-all is non-nill.  This is 
irritating when dealing with many types of file destinied for a 
preprocessor (bison, SWIG, gob, etc.) which use the %{ %} pair to delimit 
source to be included literally in the generated code, which you want to 
use c-mode to edit.

The attached file illustrates this, using the following commands:

    alitak$ 'emacs' -q test_source.gob

    M-x c-mode
    M-x hs-minor-mode
    C-u 2 M-x hs-hide-level

That big fat comment is still sitting there...

I would suggest that either:

    1. Multiline comments should be treated as blocks in this case, as 
       advertised.  This is probably not so good since some people will 
       doubtless want to see the whole comments by default.

    2. The hs-hide-comments-when-hiding-all variable should be made to 
       apply to hs-hide-level as well.

    3. A new configuration variable should be introduced to control the 
       behavior of hs-hide-level wrt comments.  Probably the best way to 
       go.

In any case, paragraph two should be rewritten a bit since comments and 
blocks clearly aren't being treated quite the same way.

A slightly surprising (though probably desirable) related behavior is 
exibited by the following command sequence:

    alitak$ 'emacs' -q test_source.gob

    M-x c-mode
    M-x hs-minor-mode
    C-u 3 M-x forward-char
    C-u 2 M-x hs-hide-level

Even though we are in a comment, which is supposed to count as a block, 
and there arent't any sub-blocks 2 levels deep to hide, we get the same 
behavior as if we hadn't moved into the comment.

Emacs version:

GNU Emacs 21.3.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 
2004-01-22 on alitak.asf.alaska.edu

Configuration command line:

./configure --prefix=/home/bkerin/local

Source modifications: None

Britton Kerin

Attachment: test_source.gob
Description: Text document


reply via email to

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