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

Patch to try out: ":unsilent"

Expand Messages
  • Bram Moolenaar
    Any comments on adding the :unsilent command modifier? ... Execute {command} not silently. Only makes a difference when |:silent| was used to get to this
    Message 1 of 8 , Jul 1, 2009
    • 0 Attachment
      Any comments on adding the ":unsilent" command modifier?

      :uns[ilent] {command}
      Execute {command} not silently. Only makes a
      difference when |:silent| was used to get to this
      command.
      Use this for giving a message even when |:silent| was
      used. In this example |:silent| is used to avoid the
      message about reading the file and |:unsilent| to be
      able to list the first line of each file. >
      :silent argdo unsilent echo expand('%') . ": " . getline(1)


      *** ../vim-7.2.221/src/ex_cmds.h 2008-11-09 13:43:25.000000000 +0100
      --- src/ex_cmds.h 2009-07-01 18:12:55.000000000 +0200
      ***************
      *** 991,996 ****
      --- 991,998 ----
      BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
      EX(CMD_unmenu, "unmenu", ex_menu,
      BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
      + EX(CMD_unsilent, "unsilent", ex_wrongmodifier,
      + NEEDARG|EXTRA|NOTRLCOM|SBOXOK|CMDWIN),
      EX(CMD_update, "update", ex_update,
      RANGE|WHOLEFOLD|BANG|FILE1|ARGOPT|DFLALL|TRLBAR),
      EX(CMD_vglobal, "vglobal", ex_global,
      *** ../vim-7.2.221/src/ex_docmd.c 2009-05-16 17:29:37.000000000 +0200
      --- src/ex_docmd.c 2009-07-01 18:48:33.000000000 +0200
      ***************
      *** 1677,1684 ****
      char_u *errormsg = NULL; /* error message */
      exarg_T ea; /* Ex command arguments */
      long verbose_save = -1;
      ! int save_msg_scroll = 0;
      ! int did_silent = 0;
      int did_esilent = 0;
      #ifdef HAVE_SANDBOX
      int did_sandbox = FALSE;
      --- 1677,1684 ----
      char_u *errormsg = NULL; /* error message */
      exarg_T ea; /* Ex command arguments */
      long verbose_save = -1;
      ! int save_msg_scroll = msg_scroll;
      ! int save_msg_silent = -1;
      int did_esilent = 0;
      #ifdef HAVE_SANDBOX
      int did_sandbox = FALSE;
      ***************
      *** 1856,1864 ****
      }
      if (!checkforcmd(&ea.cmd, "silent", 3))
      break;
      ! ++did_silent;
      ++msg_silent;
      - save_msg_scroll = msg_scroll;
      if (*ea.cmd == '!' && !vim_iswhite(ea.cmd[-1]))
      {
      /* ":silent!", but not "silent !cmd" */
      --- 1856,1864 ----
      }
      if (!checkforcmd(&ea.cmd, "silent", 3))
      break;
      ! if (save_msg_silent == -1)
      ! save_msg_silent = msg_silent;
      ++msg_silent;
      if (*ea.cmd == '!' && !vim_iswhite(ea.cmd[-1]))
      {
      /* ":silent!", but not "silent !cmd" */
      ***************
      *** 1886,1891 ****
      --- 1886,1898 ----
      #endif
      continue;

      + case 'u': if (!checkforcmd(&ea.cmd, "unsilent", 3))
      + break;
      + if (save_msg_silent == -1)
      + save_msg_silent = msg_silent;
      + msg_silent = 0;
      + continue;
      +
      case 'v': if (checkforcmd(&ea.cmd, "vertical", 4))
      {
      #ifdef FEAT_VERTSPLIT
      ***************
      *** 2684,2696 ****

      cmdmod = save_cmdmod;

      ! if (did_silent > 0)
      {
      /* messages could be enabled for a serious error, need to check if the
      * counters don't become negative */
      ! msg_silent -= did_silent;
      ! if (msg_silent < 0)
      ! msg_silent = 0;
      emsg_silent -= did_esilent;
      if (emsg_silent < 0)
      emsg_silent = 0;
      --- 2691,2702 ----

      cmdmod = save_cmdmod;

      ! if (save_msg_silent != -1)
      {
      /* messages could be enabled for a serious error, need to check if the
      * counters don't become negative */
      ! if (!did_emsg)
      ! msg_silent = save_msg_silent;
      emsg_silent -= did_esilent;
      if (emsg_silent < 0)
      emsg_silent = 0;
      ***************
      *** 2987,2992 ****
      --- 2993,2999 ----
      {"silent", 3, FALSE},
      {"tab", 3, TRUE},
      {"topleft", 2, FALSE},
      + {"unsilent", 3, FALSE},
      {"verbose", 4, TRUE},
      {"vertical", 4, FALSE},
      };

      --
      hundred-and-one symptoms of being an internet addict:
      42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Raúl Núñez de Arenas Coronado
      Saluton Bram :) ... I would find it very useful, specially for the example you use in the help text. Moreover, it is a very cheap command in code terms.
      Message 2 of 8 , Jul 1, 2009
      • 0 Attachment
        Saluton Bram :)

        Bram Moolenaar <B...@...> dixit:
        > Any comments on adding the ":unsilent" command modifier?

        I would find it very useful, specially for the example you use in the
        help text. Moreover, it is a very "cheap" command in code terms.

        Thanks for adding the command :)

        --
        Raúl "DervishD" Núñez de Arenas Coronado
        Linux Registered User 88736 | http://www.dervishd.net
        It's my PC and I'll cry if I want to... RAmen!

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tony Mechelynck
        ... [...] Looks interesting. Assuming that Vim s behaviour won t change if it isn t used, and considering, as Raúl said, the small cost in terms of code, why
        Message 3 of 8 , Jul 1, 2009
        • 0 Attachment
          On 01/07/09 18:55, Bram Moolenaar wrote:
          > Any comments on adding the ":unsilent" command modifier?
          [...]

          Looks interesting. Assuming that Vim's behaviour won't change if it
          isn't used, and considering, as Raúl said, the small cost in terms of
          code, why not?


          Best regards,
          Tony.
          --
          Here in my heart, I am Helen;
          I'm Aspasia and Hero, at least.
          I'm Judith, and Jael, and Madame de Staël;
          I'm Salome, moon of the East.

          Here in my soul I am Sappho;
          Lady Hamilton am I, as well.
          In me Récamier vies with Kitty O'Shea,
          With Dido, and Eve, and poor nell.

          I'm all of the glamorous ladies
          At whose beckoning history shook.
          But you are a man, and see only my pan,
          So I stay at home with a book.
          -- Dorothy Parker

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Matt Wozniski
          ... It seems like a good idea, if only for the symmetry. Any chance for another change to how :silent works, though, while we re at it? I d find it very
          Message 4 of 8 , Jul 1, 2009
          • 0 Attachment
            On Wed, Jul 1, 2009 at 12:55 PM, Bram Moolenaar wrote:
            >
            > Any comments on adding the ":unsilent" command modifier?

            It seems like a good idea, if only for the symmetry. Any chance for
            another change to how :silent works, though, while we're at it? I'd
            find it very useful in my own scripts if

            :silent echomsg "hello"

            could be used to write a message to the :messages log without
            displaying it to the screen. I was surprised when I found out that
            this didn't work, but of course in retrospect that would have required
            that :echomsg have been special-cased in the code. Maybe we could add
            a :msgonly modifier that behaves like :silent but does add to the
            message history?

            ~Matt

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Bram Moolenaar
            ... The message history is to store displayed messages. If a message isn t displayed then it should not be in the history. If you want to log some things to
            Message 5 of 8 , Jul 2, 2009
            • 0 Attachment
              Matt Wozniski wrote:

              > On Wed, Jul 1, 2009 at 12:55 PM, Bram Moolenaar wrote:
              > >
              > > Any comments on adding the ":unsilent" command modifier?
              >
              > It seems like a good idea, if only for the symmetry. Any chance for
              > another change to how :silent works, though, while we're at it? I'd
              > find it very useful in my own scripts if
              >
              > :silent echomsg "hello"
              >
              > could be used to write a message to the :messages log without
              > displaying it to the screen. I was surprised when I found out that
              > this didn't work, but of course in retrospect that would have required
              > that :echomsg have been special-cased in the code. Maybe we could add
              > a :msgonly modifier that behaves like :silent but does add to the
              > message history?

              The message history is to store displayed messages. If a message isn't
              displayed then it should not be in the history.

              If you want to log some things to see what your plugin is doing you can
              use a global List and append to that.

              --
              The real
              trick is
              this: to
              keep the
              lines as
              short as
              possible
              and keep
              the size
              the same
              yet free
              from the
              need for
              hyphena-
              Dammit!! (Matthew Winn)

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ download, build and distribute -- http://www.A-A-P.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Matt Wozniski
              Oops, accidentally sent this to Bram off-list. ... It just seems that it would be nicer if each plugin didn t need to roll its own ad-hoc logging solution.
              Message 6 of 8 , Jul 2, 2009
              • 0 Attachment
                Oops, accidentally sent this to Bram off-list.

                Bram Moolenaar wrote:
                >
                > Matt Wozniski wrote:
                >
                >> Bram Moolenaar wrote:
                >> >
                >> > Any comments on adding the ":unsilent" command modifier?
                >>
                >> Maybe we could add
                >> a :msgonly modifier that behaves like :silent but does add to the
                >> message history?
                >
                > The message history is to store displayed messages.  If a message isn't
                > displayed then it should not be in the history.
                >
                > If you want to log some things to see what your plugin is doing you can
                > use a global List and append to that.

                It just seems that it would be nicer if each plugin didn't need to
                roll its own ad-hoc logging solution.  When something goes wrong, a
                lot of experienced vim users will instinctively check :messages to see
                if an error managed to slip by them unnoticed, so the message history
                seems like an intuitive place to do logging.  It not only would save
                plugin authors the need to roll their own logging solution, but would
                save plugin users from having to learn which plugins do provide their
                own logging, and learning how to view the log for each.

                It's not something I feel terribly strongly about one way or the
                other, but I definitely think that extending the message history from
                it's current definition to "A list of messages that can give you
                insight about what happened recently" would be more useful.

                ~Matt

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Ingo Karkat
                ... I guessed you would want this for debugging / logging, though one has to differentiate: If the plugin really needs to inform the user about something, ...
                Message 7 of 8 , Jul 2, 2009
                • 0 Attachment
                  On 02-Jul-09 22:47, Matt Wozniski wrote:
                  > Bram Moolenaar wrote:
                  >> Matt Wozniski wrote:
                  >>> Bram Moolenaar wrote:
                  >>>> Any comments on adding the ":unsilent" command modifier?
                  >>> Maybe we could add
                  >>> a :msgonly modifier that behaves like :silent but does add to the
                  >>> message history?
                  >> The message history is to store displayed messages. If a message isn't
                  >> displayed then it should not be in the history.
                  >>
                  >> If you want to log some things to see what your plugin is doing you can
                  >> use a global List and append to that.
                  >
                  > It just seems that it would be nicer if each plugin didn't need to
                  > roll its own ad-hoc logging solution. When something goes wrong, a
                  > lot of experienced vim users will instinctively check :messages to see
                  > if an error managed to slip by them unnoticed, so the message history
                  > seems like an intuitive place to do logging. It not only would save
                  > plugin authors the need to roll their own logging solution, but would
                  > save plugin users from having to learn which plugins do provide their
                  > own logging, and learning how to view the log for each.
                  >
                  > It's not something I feel terribly strongly about one way or the
                  > other, but I definitely think that extending the message history from
                  > it's current definition to "A list of messages that can give you
                  > insight about what happened recently" would be more useful.

                  I guessed you would want this for debugging / logging, though one has to
                  differentiate: If the plugin really needs to inform the user about something,
                  :echomsg fits perfectly, and the message should also be visible. If this is
                  internal, implementation-specific tracing stuff for debugging by plugin writers
                  or troubleshooting, this should normally be hidden from view.

                  For the latter purpose, I use :echomsg during development, and comment out these
                  before moving the script into production. I know about Dr.Chip's Decho plugin,
                  which provides much more functionality in that area. Of course, as a plugin
                  author, I would love to have :tracemsg, :set trace=myscript,yourscript and :set
                  tracefile=/tmp/trace.log commands built-in. But I don't think these should be
                  combined into the :messages functionality.

                  -- just my two cents, ingo
                  --
                  -- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
                  -- http://vim.sourceforge.net/account/profile.php?user_id=9713 --


                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Bram Moolenaar
                  ... Look at the stuff that Charles Campbell made. I don t think that uniform logging will help, really. I mean, what s simpler than: let g:mylog = [] ...
                  Message 8 of 8 , Jul 3, 2009
                  • 0 Attachment
                    Matt Wozniski wrote:

                    > Oops, accidentally sent this to Bram off-list.
                    >
                    > Bram Moolenaar wrote:
                    > >
                    > > Matt Wozniski wrote:
                    > >
                    > >> Bram Moolenaar wrote:
                    > >> >
                    > >> > Any comments on adding the ":unsilent" command modifier?
                    > >>
                    > >> Maybe we could add
                    > >> a :msgonly modifier that behaves like :silent but does add to the
                    > >> message history?
                    > >
                    > > The message history is to store displayed messages. Â If a message isn't
                    > > displayed then it should not be in the history.
                    > >
                    > > If you want to log some things to see what your plugin is doing you can
                    > > use a global List and append to that.
                    >
                    > It just seems that it would be nicer if each plugin didn't need to
                    > roll its own ad-hoc logging solution. Â When something goes wrong, a
                    > lot of experienced vim users will instinctively check :messages to see
                    > if an error managed to slip by them unnoticed, so the message history
                    > seems like an intuitive place to do logging. Â It not only would save
                    > plugin authors the need to roll their own logging solution, but would
                    > save plugin users from having to learn which plugins do provide their
                    > own logging, and learning how to view the log for each.
                    >
                    > It's not something I feel terribly strongly about one way or the
                    > other, but I definitely think that extending the message history from
                    > it's current definition to "A list of messages that can give you
                    > insight about what happened recently" would be more useful.

                    Look at the stuff that Charles Campbell made.

                    I don't think that "uniform logging" will help, really. I mean, what's
                    simpler than:

                    let g:mylog = []

                    ...

                    call add(g:mylog, "I did something!")

                    ...

                    echo g:mylog

                    --
                    hundred-and-one symptoms of being an internet addict:
                    53. To find out what time it is, you send yourself an e-mail and check the
                    "Date:" field.

                    /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                    /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                    \\\ download, build and distribute -- http://www.A-A-P.org ///
                    \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.