Monday, April 5, 2021

vimscript & buffers

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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/9f51b6dd-470c-f99b-1126-e6be6290cf23%40googlemail.com.

No comments: