unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* hs-hide-level doesn't hide multiline comments in C mode
@ 2004-01-22 21:48 Britton Kerin
  0 siblings, 0 replies; only message in thread
From: Britton Kerin @ 2004-01-22 21:48 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 2238 bytes --]


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 #2: Type: TEXT/PLAIN, Size: 517 bytes --]

/* A C-like file that gets preprocessed and therefore offers a way to
   include literal C code (using the common %{ %} mechanism).  */

/* Begin literal code.  */
%{

/* A long-winded multiline comment describing the function
   some_function.  This comment drones on an on and on telling you
   every little thing the function does.  Its long enough that you
   want hs-hide-level to hide it like a block, as advertised.  */ 
static void
some_function (void)
{
  /* Some function body.  */
}

%}


[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-gnu-emacs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-01-22 21:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-22 21:48 hs-hide-level doesn't hide multiline comments in C mode Britton Kerin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).