Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move functions to autoload dir. #52

Closed
wants to merge 5 commits into from
Closed

Conversation

lucc
Copy link

@lucc lucc commented Nov 23, 2015

This has been mentioned in #13 but I thought I could just go ahead and do it.

The main advantage is the speed up of startup time (script source time) as reported by --startuptime.
On master it is 1.1 msec and on this branch 0.3 msec for me. This is especially useful when you start vim and do not intend to edit a gpg file.

@lucc
Copy link
Author

lucc commented Sep 14, 2016

Bump: rebased after some changes in master.

@Konfekt
Copy link

Konfekt commented Sep 14, 2016

The functions must be named gpg#... Instead of s:...

@jamessan
Copy link
Owner

Thanks for updating this, @lucc. I haven't forgotten. I'm just waiting to merge until I get a new release of Debian's vim-addon-manager out that way I don't prevent getting updates of this addon into Debian.

@lucc
Copy link
Author

lucc commented Sep 14, 2016

@Konfekt which functions specifically. If I execute grep '^function' **/*.vim I get these results:

on master:

plugin/gnupg.vim:function s:shellescape(s, ...)
plugin/gnupg.vim:function s:GPGInit(bufread)
plugin/gnupg.vim:function s:GPGCleanup()
plugin/gnupg.vim:function s:GPGDecrypt(bufread)
plugin/gnupg.vim:function s:GPGEncrypt()
plugin/gnupg.vim:function s:GPGViewRecipients()
plugin/gnupg.vim:function s:GPGEditRecipients()
plugin/gnupg.vim:function s:GPGFinishRecipientsBuffer()
plugin/gnupg.vim:function s:GPGViewOptions()
plugin/gnupg.vim:function s:GPGEditOptions()
plugin/gnupg.vim:function s:GPGFinishOptionsBuffer()
plugin/gnupg.vim:function s:GPGCheckRecipients(tocheck)
plugin/gnupg.vim:function s:GPGNameToID(name)
plugin/gnupg.vim:function s:GPGIDToName(identity)
plugin/gnupg.vim:function s:GPGPreCmd()
plugin/gnupg.vim:function s:GPGPostCmd()
plugin/gnupg.vim:function s:GPGSystem(dict)
plugin/gnupg.vim:function s:GPGExecute(dict)
plugin/gnupg.vim:function s:GPGDebug(level, text)

on this PR:

autoload/gnupg.vim:function s:shellescape(s, ...)
autoload/gnupg.vim:function gnupg#GPGInit(bufread)
autoload/gnupg.vim:function gnupg#GPGCleanup()
autoload/gnupg.vim:function gnupg#GPGDecrypt(bufread)
autoload/gnupg.vim:function gnupg#GPGEncrypt()
autoload/gnupg.vim:function gnupg#GPGViewRecipients()
autoload/gnupg.vim:function gnupg#GPGEditRecipients()
autoload/gnupg.vim:function s:GPGFinishRecipientsBuffer()
autoload/gnupg.vim:function gnupg#GPGViewOptions()
autoload/gnupg.vim:function gnupg#GPGEditOptions()
autoload/gnupg.vim:function s:GPGFinishOptionsBuffer()
autoload/gnupg.vim:function s:GPGCheckRecipients(tocheck)
autoload/gnupg.vim:function s:GPGNameToID(name)
autoload/gnupg.vim:function s:GPGIDToName(identity)
autoload/gnupg.vim:function s:GPGPreCmd()
autoload/gnupg.vim:function s:GPGPostCmd()
autoload/gnupg.vim:function s:GPGSystem(dict)
autoload/gnupg.vim:function s:GPGExecute(dict)
autoload/gnupg.vim:function s:GPGDebug(level, text)

So you can see that I already changed the functions that need to be changed. All the other functions are only called from within the same file and can still be script-local. Please point me to the function in question if I'm wrong.

@Konfekt
Copy link

Konfekt commented Sep 14, 2016

Alright, I read the commit wrongly. It's all fine, sorry for the noise.

@blueyed
Copy link
Contributor

blueyed commented Dec 11, 2016

It would be nice to have a single (autoload) function that allows for init+loading, so that it can be used when lazy-loading this in a plugin manager.

The "GPG" prefix is not needed anymore.  All public functions now have the
prefix "gnupg#" and all script local functions did not need to be put in a
separate "namespace" all along.  Same for variables.
@lucc
Copy link
Author

lucc commented Feb 25, 2017

@jamessan I rebased ontop of master.

@blueyed Can you open a feature request for this? I don't use special settings or plugin managers to only load plugins in special conditions (hence this PR for a little sped up :), so I have little understanding of what is needed for this.

@blueyed
Copy link
Contributor

blueyed commented Sep 7, 2017

@jamessan
Can we make this happen, please? (moving the plugin's core into autoload)

I could pick it up to resolve the conflict, if you or @lucc do not want to do it.

@blueyed
Copy link
Contributor

blueyed commented Sep 7, 2017

Just for reference, I am using the following now to autoload it with vim-plug:

    Plug 'jamessan/vim-gnupg', {'on': []}  " custom filetype
    " Manual setup for autoloading
    let g:GPGFilePattern = '*.\(gpg\|asc\|pgp\)'
    function! s:autoload_gnupg(aucmd)
      augroup MyGnuPG
        au!
      augroup END
      call plug#load('vim-gnupg')
      exe 'doautocmd' a:aucmd
    endfunction
    augroup MyGnuPG
      autocmd!
      autocmd BufReadCmd *.\(gpg\|asc\|pgp\) call s:autoload_gnupg('BufReadCmd')
      autocmd FileReadCmd *.\(gpg\|asc\|pgp\) call s:autoload_gnupg('FileReadCmd')
    augroup END

@jamessan
Copy link
Owner

jamessan commented Sep 7, 2017

Can we make this happen, please? (moving the plugin's core into autoload)

It will happen, but my comment from earlier still stands.

Right now I'd rather spend my time on this plugin figuring out a way to get it to work with Neovim or improving the detection of armored files. Restructuring the plugin is nice, but it's not a priority.

@blueyed
Copy link
Contributor

blueyed commented Sep 7, 2017

@jamessan
Cool!

figuring out a way to get it to work with Neovim

It works for me there?!
What are you referring to?

@blueyed
Copy link
Contributor

blueyed commented Sep 7, 2017

Restructuring the plugin is nice, but it's not a priority.

I agree. But given an existing PR already, that will cause conflicts over and over again.

Good to know where you stand there though, so we can wait with updating this PR.

(and there is a workaround for vim-plug, which can be adopted for other plugin managers likely, so it is fine for me in this regard)

@blueyed
Copy link
Contributor

blueyed commented Sep 7, 2017

Neovim

Ah, #32 - I am using gpg-agent (and asymmetric encryption), so this works around this I guess?!

@jamessan
Copy link
Owner

jamessan commented Sep 7, 2017

I am using gpg-agent (and asymmetric encryption), so this works around this I guess?!

If you have a GUI pinentry, then that will avoid the problem, yes.

@jamessan jamessan closed this in 44372d8 Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants