vimscript & buffers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

vimscript & buffers

Johannes Köhler
Hello Vim(script) developers,
   
   because i never did a post in this group list before:
   
   "Dear all. My name is kefko (i have
   some more alias, but thats my current
   one, for computer hacking...) My real name youll find in
   the from. I am not doing dangerous computer hacking
   that because iam not encrypt everything and
   using my real(m) name in plain text, also.
   The Kefko acrnym is inspired by
   Kefka from the Final Fantasy Series. My gaming hobby...
   Since my early ages, right now i am middle-aged,
   i like computers and sports
   (strange combination but math combination are
   strange,also ;) - sincerely"
   
   My first post is related to a problem i currently have
   with vimscript. Maybe i will find some help
   here, or someone can give me an alternative #address
   (eg i use comp*editors: and yes, i did read the vim documentation
   as much as possible - a lot :)
   
   = I have to write a vimscript Plugin for VIM
   to use the webservice by gnu inetutils (ftp)
   together with the vimwiki Plugin to have
   an centralized vimwiki. ("The hacker community
   in germany (CCC) is by political principle decentralized
   orientated and organized, but i am already not a member meanwhile,
   so i think its ok to have an centralized vimwiki.")
   
   OR: Anyone knowing a plugin to expand the vimwiki online?
   (on my android 4.* phone it should work, thats because
   i cannot use DAV... FTP should work with busybox)

   -> VIM PLUGIN
   #0: Getting Vimwiki files per FTP
   #0.1: Creating Vimwiki when not @FTPSERVER
   #0.2: Opening and Using Vimwiki
   #1: Closing Vimwiki and send/write back to FTP
   #1.1: Copy a backup to a directory@FTP
   
   Im not using vim9script because i want
   during programming to think like the vimscript
   Interpreter and not like a vim9 Compiler.

   USING: netrw & vimwiki Plugin
   
   -> IDEA
   Because i dont want to interfere with other
   PLUGINS and SCRIPTS,

   iam trying the following:
   
   Loading the Pluginsource by runtimepath
   (while development :so [...])
   
   AfterSourcing: Definition of some global variables
   and one START function
   
   When starting at point #0 (Plugin) by normal mode command:
   
   Call this START function, within create and goto new BUFFER
   create new LOCALDATA (nested subfunctions,
   and autocommands + variable): not until with this
   point, that new defined functions are a global vim definition
   (by interpreter logic...?)
   
   -> AIM
   1) when wipeout this BUFFER the VIM data is also
   tidy clean and i can (eg) source my Pluginsource again
   - without sticking into problems with type save
   2) the script is in running state (while loop)
   - waiting for autocommand event
   - interact with the vimwiki (send and receive files
   from the ftpserver)

   -> SOURCE OF START FUNKTION CALLED BY NORMAL MODE COMMAND
   
   function s:Start()
   
   if !has('vim9script')
   
      try
   
      let g:flag = v:true
 
      function s:Wipe(buffer) abort
         let s:command = 'bwipeout! ' .. a:buffer
         :execute s:command
      endfunction
   
      function s:flagset() abort
         let g:flag = v:false
      endfunction
   
      augroup ScriptAugroup
   
      let s:buffer = bufadd('ScriptBuffer')
      let s:bufferName = bufname(s:buffer)
      call bufload(s:bufferName)
   
      if bufloaded(s:buffer) == v:true
   
         "GOTO BUFFER
         let b:command = 'buffer! ' .. s:buffer
         :execute b:command
   
         "NOW USING BUFFER LOCAL FUNCTIONS AND VAR
         au BufLeave * call s:flagset()

         "DEFINE NEW FUNCTIONS AND Stuff
         function b:Bla()
            do sth
         endfunction
         let b:blub = "sth"
   
         "THEN WAIT
         while g:flag

            execute :VimwikiIndex

            "Nread/Nwrite from netrw plugin:
            "possible to send and receive files
            "when vimwiki is writing

            "waiting till ftp server is reachable

            "g:flag gets false when
            "autocommand BufLeave is triggered by
            "vimwiki during new buffer is existing
   
         endwhile
      else
         finish
      endif
   
      " Delete all Definitions
      call s:Wipe(s:buffer)
      augroup END
      au! ScriptAugroup *
      augroup! ScriptAugroup
   
      catch /.*/
         :echoerr v:exception
         :echoerr v:errmsg
      finally
     endtry
   endif
   
   endfunction
 

   -> ?PROBLEM!
   
   The while LOOP is not waiting for the g:flag getting
   TRUE by autocommand. It seems like the Interpreter
   is not accepting running loop after sourcing?

   Maybe someone can tell me a solution for this problem.
   Another idea i had during writing: Spitting it into
   more functions and calling a clearance function
   for doing the stuff after the terminated while loop...

   BUT: then i have a problem due to live interacting with the
   ftp server...

  THX!

--
Wonderful VIM DOCS:
When a mapping triggers itself, it will run forever
WEBwww.johannes-koehler.de  <http://www.johannes-koehler.de>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/9f51b6dd-470c-f99b-1126-e6be6290cf23%40googlemail.com.
Reply | Threaded
Open this post in threaded view
|

Re: vimscript & buffers

Johannes Köhler
On 05.04.21 11:46, kefko wrote:
> Hello Vim(script) developers,
>
> [...]
>

UPDATE to my posting (maybe someone gets triggered)

Question: Is it possible to use vim buffers like vim threads?

Means, if i have a running loop inside of my first buffer,
then creating a new buffer, loading this and working on it,
my previous buffer is still in running state without a vim freeze...

WHY?

then i would have the possibility for VIMWIKI2WEB
 

a T(ea) Mug Idea (with running state buffer)

 

Use vimwiki vim plugin from different platforms with the
same vimwiki Index (same wiki). Using: 1 - Android vimtouch
and busybox ftp OR 2 - X86-64 vim 8 & gnu inetutils ftp

 

    Why not droidvim&googledrive?
 

    should run on a cheap portable platform:
    Android 4.1 @ Samsung galaxy star
    -> a singlecore 32bit ARM Cortex A5@1000MHz

    10€@ebay :) -> yes, "a better pad of paper" and i dont have
    to care about where to find it, or if someone is
    taking it without my knowing ( -> thugs, thiefs or girlfriends...)
    On my PC vim, of course - also.
 

Name of the vim wiki plugin: Vimwiki2web.vim
 

   DEV
 

   #1 source Plugin @ runtimepath or vim pack
 

      normal mode commands (+ mapping)
 

         -> Vimwiki2web Open : start()
 

   #2 start()
 

         -> definitions, inside of new buffer
 

            function: close()
            mappings: for vimwiki plugin (because of vimtouch)
               and the close calling of vimwiki2web
            variables for vimwiki2web
            autocmds for vimwiki2web
 

         -> Open(running state - per loop):
 

            :1 Waiting till ftp is available (ping)
            :2 Get wiki directory from ftp (plain text)
            :2.1 when not there → create new one
            :3 open wiki
            :3.1 when changed files@ftp server: reload wiki files
               (netrw-dirlist inside of a time interval)
            :3.2 when changed files@localhost: write to ftp
               (on autocommands Buf*)
            :3.3 questions on data consisteny: backup files
 

         -> Close():
 

            :4 Buffer vimwiki close
            :4.1 wipeout buffer
            :4.2 deleting local files

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/3b609868-7eab-e176-46f7-c63b9c59807b%40googlemail.com.