Loading ...
Sorry, an error occurred while loading the content.

60ah: some folding issues

Expand Messages
  • Zdenek Sekera
    I ve played with folds trying to figure out what would be the best way me to use them in everyday work and came accross a few surprizes and possibly
    Message 1 of 5 , Jun 1, 2001
    • 0 Attachment
      I've played with folds trying to figure out what would be the best
      way me to use them in everyday work and came accross a few
      surprizes and possibly inconsistencies that I'd appreciate
      somebody to explain them to me:


      Take this 'test.c' as an example:

      ------- test.c start ---------
      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      long long a;
      int b, c;

      if (*atob_L(argv[1], &a)) {
      printf("Can't decode 'a' number: %s\n", argv[1]);
      } else {
      f(a, &b, &slice);
      error(c, b, printf);
      }

      return 0;
      }
      ------- test.c end ------------

      vim test.c
      :set foldmethod=indent

      The screen will show:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      +-- 11 lines: long long a;--------------------------------------
      }

      Q1: I find too bad one cannot click on that fold line and open it
      (or maybe just on that '+' in col 1, that would be nice.

      ======================

      :set foldcolumn=1

      screen will show:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      ++-- 11 lines: long long a;-----------------------------------
      }

      Q2: I have to now click *twice* on the leading '+' to open that fold,
      first click seems to be doing something but I can't grasp what.
      Why twice?

      Q3: When I open it, there is no way I can find to close it again
      just by a mouse click. Why?

      =======================

      When I open it I see:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      long long a;
      int b, c;

      if (*atob_L(argv[1], &a)) {
      printf("Can't decode 'a' number: %s\n", argv[1]);
      } else {
      ++---- 2 lines: f(a, &b, &slice);-------------------------------
      }

      return 0;
      }

      So there is a second fold, fair enough. Double click on leading '+'
      will open it. OK.

      ================================
      Close both and start like this:

      :set fdc=2 screen will show:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      + +-- 11 lines: long long a;------------------------------------
      }

      Now first click on leading '+' will show:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      -++--- 11 lines: long long a;--------------------------------------
      }

      Q4: what state does it show? I can't see what happened (yes, I can see
      the '+ ' has changed to '-+' but otherwise the screen appearance
      hasn't changed, but it's trying to tell me something, what?)

      ======================

      The click on the first '+' (it's not the leading one now) will
      open the fold:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      - long long a;
      2 int b, c;
      2
      2 if (*atob_L(argv[1], &a)) {
      - printf("Can't decode 'a' number: %s\n", argv[1]);
      2 } else {
      2++---- 2 lines: f(a, &b, &slice);--------------------------------
      2 }
      2
      2 return 0;
      }

      First click on the first '+' on the second level fold will again change
      some state but what? The second one will open it.

      We'll see this:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      - long long a;
      2 int b, c;
      2
      2 if (*atob_L(argv[1], &a)) {
      - printf("Can't decode 'a' number: %s\n", argv[1]);
      2 } else {
      - f(a, &b, &slice);
      4 error(c, b, printf);
      2 }
      2
      2 return 0;
      }


      Q5: we jump from level two to level 4 directly.
      Where is the level 3 fold ????

      =========================

      Now :set fdc=3 and we'll see:

      int
      dump(int argc, char *argv[], char *argp[], struct cmd_table *xxx)
      {
      -- long long a;
      || int b, c;
      ||
      || if (*atob_L(argv[1], &a)) {
      -- printf("Can't decode 'a' number: %s\n", argv[1]);
      || } else {
      -- f(a, &b, &slice);
      34 error(c, b, printf);
      || }
      ||
      || return 0;
      }

      Q6: there seem to be some showing of level 3 (which I would think
      to be correct) but I can't see why we are getting level 4.

      ===========================

      I would now expect the paralel bars '||' to handle level 1 (first
      one) and level 2 (the second one). It's mostly so, however, click
      on the second '|' of the 'return 0' line.

      Q7: this will close *all* folds. Is that correct?

      ---Zdenek
    • Pritesh Mistry
      Q1: I find too bad one cannot click on that fold line and open it (or maybe just on that + in col 1, that would be nice. Ans: You can, in the foldcolumn.
      Message 2 of 5 , Jun 1, 2001
      • 0 Attachment
        Q1: I find too bad one cannot click on that fold line and open it
        (or maybe just on that '+' in col 1, that would be nice.

        Ans: You can, in the foldcolumn.

        ======================

        Q2: I have to now click *twice* on the leading '+' to open that fold,
        first click seems to be doing something but I can't grasp what.
        Why twice?

        Q3: When I open it, there is no way I can find to close it again
        just by a mouse click. Why?

        Ans: You can. Hope you have the mouse properly set up! With my
        gvim60af/win2k, it takes only a single click to open & close
        the folds.

        =======================

        Q4: what state does it show? I can't see what happened (yes, I can see
        the '+ ' has changed to '-+' but otherwise the screen appearance
        hasn't changed, but it's trying to tell me something, what?)

        Ans: I think your 11 line code has two indents, hence taking an extra
        click to open up the second. As you can see, the first + has
        become -.

        ======================

        Q5: we jump from level two to level 4 directly.
        Where is the level 3 fold ????

        Ans: Same reason as Q4. Check your shiftwidth/tabstop.

        =========================

        Q6: there seem to be some showing of level 3 (which I would think
        to be correct) but I can't see why we are getting level 4.

        Ans: Same reason as Q4. Check your shiftwidth/tabstop.

        ===========================

        Q7: this will close *all* folds. Is that correct?

        Ans: I think, you could best stick to fdc=2 to avoid the confusion.
        Or, may be you could set the fdc to max indent + 1 & see the
        display, if that could explain.

        HTH!
        Pritesh
      • Zdenek Sekera
        ... Yes, I know, but why do I need to set fdc != 0 for this? Why shouldn t be sufficient to click on the existing + (or actually even better *anywhere* on
        Message 3 of 5 , Jun 1, 2001
        • 0 Attachment
          Pritesh Mistry wrote:
          >
          > Q1: I find too bad one cannot click on that fold line and open it
          > (or maybe just on that '+' in col 1, that would be nice.
          >
          > Ans: You can, in the foldcolumn.
          >

          Yes, I know, but why do I need to set fdc != 0 for this?
          Why shouldn't be sufficient to click on the existing '+'
          (or actually even better *anywhere* on the folded line)?

          > ======================
          >
          > Q2: I have to now click *twice* on the leading '+' to open that fold,
          > first click seems to be doing something but I can't grasp what.
          > Why twice?
          >
          > Q3: When I open it, there is no way I can find to close it again
          > just by a mouse click. Why?
          >
          > Ans: You can. Hope you have the mouse properly set up! With my
          > gvim60af/win2k, it takes only a single click to open & close
          > the folds.
          >
          > =======================
          >
          > Q4: what state does it show? I can't see what happened (yes, I can see
          > the '+ ' has changed to '-+' but otherwise the screen appearance
          > hasn't changed, but it's trying to tell me something, what?)
          >
          > Ans: I think your 11 line code has two indents, hence taking an extra
          > click to open up the second. As you can see, the first + has
          > become -.
          >
          > ======================
          >
          > Q5: we jump from level two to level 4 directly.
          > Where is the level 3 fold ????
          >
          > Ans: Same reason as Q4. Check your shiftwidth/tabstop.
          >
          > =========================
          >

          I think I understand now, first click opens a fold that I cannot
          se...., hmmmm...

          Right right, my sw=4 and ts=8, but there is no code at sw=4 to
          fold! What I am saying is this, with these settings my example
          code starts at col:1, col:9, col:17, that's beginning of line,
          2*sw+1, 4*sw+1, so from two things one: either I should see
          indents marked levels 1 3 5 (those in between are invisible since
          there is no code there but the algorithm creats them because it's
          based on the sw), or there should be marked 1, 2, 3 which
          is actually what can be really *seen* on the screen (when you
          look at those folds, you can see only 3). I would understand both
          approaches (and reasons for them and wouldn't mind either) should
          this numbering be consistent, but is it?

          ...
          >
          > Q7: this will close *all* folds. Is that correct?
          >
          > Ans: I think, you could best stick to fdc=2 to avoid the confusion.
          > Or, may be you could set the fdc to max indent + 1 & see the
          > display, if that could explain.

          Well, I am not sure if the behaviour should depend on fdc.
          One can reproduce it with different ones. I think fdc=3 actually
          shows it the best. Why does it close all folds? Maybe there is
          a reason but I don't see it.

          Thanks!

          ---Zdenek
        • Pritesh Mistry
          Yes, I know, but why do I need to set fdc != 0 for this? Why shouldn t be sufficient to click on the existing + (or actually even better *anywhere* on the
          Message 4 of 5 , Jun 1, 2001
          • 0 Attachment
            Yes, I know, but why do I need to set fdc != 0 for this?
            Why shouldn't be sufficient to click on the existing '+'
            (or actually even better *anywhere* on the folded line)?

            > ======================

            Me!: May be that's not the best way of doing it. Because many people
            would prefer to select the contents of the folds with the mouse in
            order to cut/copy it.

            I feel the closest that you could get with this is - click with
            your mouse to position the cursor on the fold & use <space> to
            open it with your other hand.

            HTH!
            Pritesh
          • Zdenek Sekera
            ... Oh thanks! This is great, didn t know it, thanks for a hint, I like it!
            Message 5 of 5 , Jun 1, 2001
            • 0 Attachment
              Pritesh Mistry wrote:
              >
              > Yes, I know, but why do I need to set fdc != 0 for this?
              > Why shouldn't be sufficient to click on the existing '+'
              > (or actually even better *anywhere* on the folded line)?
              >
              > > ======================
              >
              > Me!: May be that's not the best way of doing it. Because many people
              > would prefer to select the contents of the folds with the mouse in
              > order to cut/copy it.
              >
              > I feel the closest that you could get with this is - click with
              > your mouse to position the cursor on the fold & use <space> to
              > open it with your other hand.

              Oh thanks! This is great, didn't know it, thanks for a hint,
              I like it!

              ---Zdenek
            Your message has been successfully submitted and would be delivered to recipients shortly.