emacs-devel
[Top][All Lists]
Advanced

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

New feature proposal for Emacs


From: Teemu . Parkkinen
Subject: New feature proposal for Emacs
Date: Thu, 5 Feb 2004 10:38:02 +0200

Hi everyone!

I have an idea what would be quite helpful when editing long source-code
files.
I'm not sure if this is already implemented, but anyway:

Consider a long source-file. It is difficult to edit, because you have to
flip pages
often to see other parts of the file. Below, we have a c-file that has some
code in it.

---------------- Begin example code ----------------------

/* includes */
#include <stdio.h>
#include "someOther.h"
...


/* system initialization function */
int initSystem(int* params)
{

      /* check parameter values */
      if ( param[0] == 1 )
            return ILLEGAL_VALUE;
      if ( param[1] == 1 )
            return ILLEGAL_VALUE;
      if ( param[2] == 1 )
            return ILLEGAL_VALUE;
      if ( param[3] == 1 )
            return ILLEGAL_VALUE;
      if ( param[4] == 1 )
            return ILLEGAL_VALUE;

      /* process input parameters */
      if (params[0] == 1)
            do_things();
      if (params[1] == 2)
            do_Something_else();

      /* copy parameter tables */
      for (int i=0; i<paramlength; i++)
      {
            variables[i] = params[i];
      }

      /* check hardware status */
      for (int i=0; i<HW_PORTS; i++)
      {
            /* read value from hw-port */
            value = readHwPort(i);
            /* check that the value was within allowed range */
            if (value > MAX)
                  return HW_ERROR;
            if (value < MIN)
                  return HW_ERROR;
      }

}

-----------  end example code -------------


When editing real source files, you often want to see only a small part of
the code
when other parts are meaningless at that time. It would be enough to see
only a comment
line of those meaningless blocks that says what that block does. (And very
often one
comments the blocks already this way).

So here is the idea:

Would it be possible to hide certain blocks of code (or hide all and show
only those you wish
to see) by some way? When a block is hidden, only the first comment of it
is shown.


Let me illustrate this with the example code:

We wish to edit only the part that processes the input parameters. We
select "show-this-block"
and Emacs expands that block. At this time the source code would look like
this:

---------------- Begin example code2 ----------------------

/* includes */

/* system initialization function */
int initSystem(int* params)
{

      /* check parameter values */

      /* process input parameters */
      if (params[0] == 1)
            do_things();
      if (params[1] == 2)
            do_Something_else();

      /* copy parameter tables */

      /* check hardware status */
}

-----------  end example code2 -------------

This example code is small and very simple, but if one could hide certain
blocks from
bigger (and more complicated) file, the programmer could more easily see
what the code
really does. Very often I get confused if there are several lines of code
which does only
some very simple thing. It would be enought to see only a brief explanation
that says what is
done at this point. One could also hide entire functions, if those are not
needed at that time.

I hope you get the point what I'm trying to say. I would like to hear if
this is already implemented
(it very well may be). If it isn't, do you think this feature would be
helpful?

-Teemu







reply via email to

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