Swap directory changes when opening files under /media [Fedora]

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

Swap directory changes when opening files under /media [Fedora]

Ian-2
I'm on Fedora 25. When I open files from mounted filesystems on /media vim runs this (from vim log):

Executing BufReadPre Auto commands for "/media/*"
autocommand set directory=~/tmp,/var/tmp,/tmp

This changes my swap directory from what I want it to be and means I have swap files in two locations. How can I find out why this is happening? I set directory once in my profile:

    set directory=~/.vim/swap//

Thanks

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Ben Fritz
On Thursday, April 20, 2017 at 9:59:08 AM UTC-5, Ian wrote:

> I'm on Fedora 25. When I open files from mounted filesystems on /media vim runs this (from vim log):
>
> Executing BufReadPre Auto commands for "/media/*"
> autocommand set directory=~/tmp,/var/tmp,/tmp
>
> This changes my swap directory from what I want it to be and means I have swap files in two locations. How can I find out why this is happening? I set directory once in my profile:
>
>     set directory=~/.vim/swap//
>
> Thanks
":verbose autocmd BufReadPre" will list out all installed BufReadPre autocmds and the script file that set up the autocmd.

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Ian-2
Perfect, thanks. Here's what I get:

--- Auto-Commands ---
fedora  BufReadPre
    /media/*  set directory=~/tmp,/var/tmp,/tmp
        Last set from /etc/vimrc
    /run/media/*
              set directory=~/tmp,/var/tmp,/tmp
        Last set from /etc/vimrc
    /mnt/*    set directory=~/tmp,/var/tmp,/tmp
        Last set from /etc/vimrc
...

This lead me to /etc/vimrc which has a line:

  " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
  autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp

Which confuses me. The aim appears to be to NOT write swap files but all it does is change the location of swap files. And I do want swap files for my mounts in case of recovery.

I am tempted to remove this line though it feels a bit hacky to change this in /etc/vimrc. I will see if I can work out how to override this autocmd in my own profile perhaps.

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Ian-2
I've just added this to my profile and it has fixed the problem:

autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/.vim/swap//

Though there might be a better way to just disable the other autocmd somehow.

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Gary Johnson-4
On 2017-04-21, Ian wrote:
> I've just added this to my profile and it has fixed the problem:
>
> autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/.vim/swap//
>
> Though there might be a better way to just disable the other
> autocmd somehow.

To disable it, put this in your ~/.vimrc:

    if exists("#fedora#BufNewFile#/media/*")
        au! fedora BufNewFile /media/*
    endif
    if exists("#fedora#BufNewFile#/mnt/*")
        au! fedora BufNewFile /mnt/*
    endif
    if exists("#fedora#BufReadPre#/media/*")
        au! fedora BufReadPre /media/*
    endif
    if exists("#fedora#BufReadPre#/mnt/*")
        au! fedora BufReadPre /mnt/*
    endif

That will test for the presence of each of those autocommand events
and patterns in the fedora group and remove them.

Regards,
Gary

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Ben Fritz
In reply to this post by Ian-2
On Friday, April 21, 2017 at 5:16:17 AM UTC-5, Ian wrote:

> Perfect, thanks. Here's what I get:
>
> --- Auto-Commands ---
> fedora  BufReadPre
>     /media/*  set directory=~/tmp,/var/tmp,/tmp
> Last set from /etc/vimrc
>     /run/media/*
>               set directory=~/tmp,/var/tmp,/tmp
> Last set from /etc/vimrc
>     /mnt/*    set directory=~/tmp,/var/tmp,/tmp
> Last set from /etc/vimrc
> ...
>
> This lead me to /etc/vimrc which has a line:
>
>   " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
>   autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
>
> Which confuses me. The aim appears to be to NOT write swap files but all it does is change the location of swap files. And I do want swap files for my mounts in case of recovery.
>
>
I think the intent is not to block swap files, but rather to prevent swap files being written to removable media, which can degrade the lifetime of said media with limited write cycles before failure.

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swap directory changes when opening files under /media [Fedora]

Nikolay Aleksandrovich Pavlov
In reply to this post by Ian-2
2017-04-21 13:16 GMT+03:00 Ian <[hidden email]>:

> Perfect, thanks. Here's what I get:
>
> --- Auto-Commands ---
> fedora  BufReadPre
>     /media/*  set directory=~/tmp,/var/tmp,/tmp
>         Last set from /etc/vimrc
>     /run/media/*
>               set directory=~/tmp,/var/tmp,/tmp
>         Last set from /etc/vimrc
>     /mnt/*    set directory=~/tmp,/var/tmp,/tmp
>         Last set from /etc/vimrc
> ...
>
> This lead me to /etc/vimrc which has a line:
>
>   " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
>   autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
>
> Which confuses me. The aim appears to be to NOT write swap files but all it does is change the location of swap files. And I do want swap files for my mounts in case of recovery.
>
> I am tempted to remove this line though it feels a bit hacky to change this in /etc/vimrc. I will see if I can work out how to override this autocmd in my own profile perhaps.

Files in /etc are editable, it is OK to modify them if you are system
administrator, correct package manager must not overwrite edited files
in /etc. I would suggest to file a bug report to fedora Vim package
maintainers: these autocommands serve no purpose if &directory option
contains no `.`. Additionally they change a global option so if you
open file in /media and another file you will find out that swap files
for that another file are also put into ~/tmp, or /var/tmp, or /tmp.

>
> --
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.

--
--
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].
For more options, visit https://groups.google.com/d/optout.