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

Showing the way :intro shows

Expand Messages
  • Suresh Govindachar
    Hello, Can one create a command that shows a message in a manner similar to how :intro shows its message? If so, how? Thanks, --Suresh PS: I have a command
    Message 1 of 2 , Sep 23, 2007
    • 0 Attachment
      Hello,

      Can one create a command that shows a message in
      a manner similar to how :intro shows its message?
      If so, how?

      Thanks,

      --Suresh

      PS: I have a command that displays in the command window:

      It's
      been said
      ever so often
      by many an expert
      that in ol' plain text
      one neer can get a
      round tuit, but
      just look
      here

      The longer the story, the better it will approximate a circle.




      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • A.Politz
      ... I tried to come up with such a custom intro. The biggest flaw maybe is, that I have not found a way to avoid wasting a bufnumber. I think the most of it is
      Message 2 of 2 , Jan 1, 2008
      • 0 Attachment
        Suresh Govindachar wrote:

        >Hello,
        >
        > Can one create a command that shows a message in
        > a manner similar to how :intro shows its message?
        > If so, how?
        >
        > Thanks,
        >
        > --Suresh
        >
        >PS: I have a command that displays in the command window:
        >
        > It's
        > been said
        > ever so often
        > by many an expert
        > that in ol' plain text
        > one neer can get a
        > round tuit, but
        > just look
        > here
        >
        > The longer the story, the better it will approximate a circle.
        >
        >
        >
        >
        >>
        >
        >

        I tried to come up with such a custom intro.
        The biggest flaw maybe is, that I have not found a way
        to avoid wasting a bufnumber.

        I think the most of it is self explanatory. It
        would have to be sourced from the vimrc.

        ---------------%<----------------

        if !exists("g:intro_fname")
        let g:intro_fname = $HOME.'/.vim_intro'
        endif
        let s:intro_visible = 0

        func KillIntro()
        if s:intro_visible
        let s:intro_visible = 0
        let fname = tempname()
        "Need to give it a name for the 'e!' command, which gets rid
        "of the undotree. Sadly this will waste a bufnumber.
        exec 'silent file '.fname
        silent e!
        silent 0f!
        exec 'silent bw ^'.fname.'$'
        endif
        endfun

        func ShowIntro( intro_fname )
        if !filereadable(a:intro_fname)
        echohl Error
        redraw
        echo "Introfile not readable : '".a:intro_fname."' !"
        echohl None
        return 0
        elseif !s:intro_visible
        let s:intro_visible = 1
        let cpo_save = &cpo
        "Avoid having a second associated buffer
        set cpo-=a
        exec 'silent 0r'.a:intro_fname
        exec 'set cpo='.cpo_save
        set nomodified
        return 1
        endif
        endfun

        func! WantIntro()
        return !argc() && bufnr('$') == 1 && bufname(1) == ''
        endfun

        func! WantIntroKilled()
        return line('.') != 1 || col('.') != 1 || !empty(v:insertmode) ||
        changenr() != 1
        \|| bufnr('$') != 1 || winnr('$') != 1 || tabpagenr('$') != 1
        endfun

        func! CleanUp()
        try
        au! CustomIntro *
        delf KillIntro
        delf ShowIntro
        delf WantIntro
        delf WantIntroKilled
        unlet! s:intro_visible
        unlet! g:intro_fname
        catch
        endtry
        endfun


        augroup CustomIntro
        au!
        au CursorMoved,InsertEnter,WinLeave,BufLeave * if WantIntroKilled() |
        call KillIntro() | call CleanUp() | delf CleanUp | endif
        augroup END


        "Activate
        if WantIntro()
        call ShowIntro(g:intro_fname)
        else
        call CleanUp()
        delf CleanUp
        endif

        ---------------%<----------------


        -ap


        --
        Ich hab geträumt, der Krieg wär vorbei.


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