all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Britton Kerin <bkerin@asf.alaska.edu>
Subject: hs-hide-level doesn't hide multiline comments in C mode
Date: Thu, 22 Jan 2004 12:48:54 -0900 (AKST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0401221209090.2999-200000@mail1.asf.alaska.edu> (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

                 reply	other threads:[~2004-01-22 21:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0401221209090.2999-200000@mail1.asf.alaska.edu \
    --to=bkerin@asf.alaska.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.