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

Re: Network-oriented file reading and writing

Expand Messages
  • Bram Moolenaar
    ... Nice idea. I wonder if a more generic solution would be possible. Suppose the pattern for the autocommand is not enough to decide if the text should be
    Message 1 of 4 , Feb 6, 2000
    • 0 Attachment
      Charles Campbell wrote:

      > Anyway, here's the idea: I've introduced two new autocmd events, BufReadCmd
      > and BufWriteCmd. When they're triggered they *don't* actually read or write,
      > but they execute associated command(s) (like any good autocmd does). It just
      > so happens that with the <.vimrc> inclusion given below, that the appropriate
      > Nr or Nw command gets executed, which in turn does the rcp or ftp operation
      > for you.

      Nice idea. I wonder if a more generic solution would be possible. Suppose
      the pattern for the autocommand is not enough to decide if the text should be
      read from a file or obtained with a command. Perhaps a global variable need
      to be checked. Some script would be needed to decide what to do:

      au BufReadPre <pattern> call GetText()

      fun GetText()
      if <some_condition>
      <get text with command>
      <prevent reading text from file>
      endif
      endfun

      In the situation that the text is read with a command, there needs to be some
      way to prevent the file-read action to take place. Since autocommands may
      nest, this is a bit tricky.

      --
      BEDEVERE: Oooooh!
      LAUNCELOT: No "Aaaaarrrrrrggghhh ... " at the back of the throat.
      BEDEVERE: No! "Oooooh!" in surprise and alarm!
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /-/-- Bram Moolenaar --- Bram@... --- http://www.moolenaar.net --\-\
      \ \ Vim: http://www.vim.org ICCF Holland: http://www.vim.org/iccf / /
    Your message has been successfully submitted and would be delivered to recipients shortly.