tomtom / tlib_vim

Some utility functions for VIM
http://www.vim.org/scripts/script.php?script_id=1863
GNU General Public License v3.0
173 stars 43 forks source link

Automatically purge files without confirmation (tlib#cache#MaybePurge) #9

Closed blueyed closed 13 years ago

blueyed commented 13 years ago

tlib regularly interrupts the user when starting up Vim by asking for confirmation to do the purging in tlib#cache#MaybePurge.

I would like to have a setting which would automatically purge instead of asking for confirmation, and I suggest enabling it by default.

blueyed commented 13 years ago

I've just noticed that this happens already, and that I am probably mixing something here..

Anyway, I am quite sure to have seen the Yn prompt from MaybePurge often already.

Apart from that even having to press just Enter (to dismiss the messages) disturbs your work flow. This should not get done for an informative message, although it might be meant to provide a possibillity to cancel the execution of the purge script.

% vi foobar TLib: Delete files older than 31 days from /home/user/.cache/vim/tlib TLib: Delete cache file: /home/user/.cache/vim/tlib/deldir.sh Press ENTER or type command to continue

tomtom commented 13 years ago

I think the message comes from vim (see :help press-enter). I added a variable g:tlib#cache#silent. If it evaluates to true, no messages should be displayed. Please let me know if this doesn't work.

blueyed commented 13 years ago

Thanks for adding the variable, which I have not tested yet though.

I just wanted to let you see an example of what I was seeing:

# vi foo
TLib: Delete files older than 31 days from /root/.cache/vim/tlib
TLib: Delete cache file: /root/.cache/vim/tlib/tmru/files
TLib: Could not delete some directories.
Directory removal script: /root/.cache/vim/tlib/deldir.sh
Run script to delete directories now?
[y]es, (n)o, (e)dit: 

From skimming the code the "Could not delete some directories" appears to be confusing.. it should rather say "About to delete directories, shouldn't it?

This is the state when being prompted, before pressing Enter:

cat /root/.cache/vim/tlib/deldir.sh

rm -rf '/root/.cache/vim/tlib/tmru'
# ls -l /root/.cache/vim/tlib
total 8.0K
-rw-r--r-- 1 root root   36 Sep 12 09:56 deldir.sh
drwxr-xr-x 2 root root 4.0K Sep 12 09:56 tmru/

(the directory tmru is empty).

It's the same state after purging dirs and starting Vim.

tomtom commented 13 years ago

Am I right to assume you don't move tmru any more? Otherwise it would be an error to delete the file "tmru/files".

The problem is that you cannot delete directories from vimscript, which is why we have to delete directories by means of a shell script.

I don't fully understand your last sentence. After purging dirs and starting vim, there shouldn't be a tmru directory if you don't use tmru (see above).