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

vis and entr #758

Closed
geekdrive opened this issue Apr 16, 2019 · 4 comments
Closed

vis and entr #758

geekdrive opened this issue Apr 16, 2019 · 4 comments

Comments

@geekdrive
Copy link

geekdrive commented Apr 16, 2019

Vis doesn't work with a tool like entr (https://github.com/clibs/entr) as the file on disk is not updated on write (:w). It works the first time but then fails. The file is updated on write and close (:wq).

Is there anyway to configure it so that it works? Is there anyway to force vis to flush the file to disk without closing vis.

@ninewise
Copy link
Collaborator

I was trying to reproduce this using inotifywait -m directly; I'm seeing the same. However, after this occured, other programs are ignored by ifnotifywait, as well.

% inotifywait -m --timefmt "%Y-%m-%d %H:%M:%S" --format "%T %e" testdisk.log
Setting up watches.
Watches established.
2019-04-17 09:45:31 OPEN
2019-04-17 09:45:31 ACCESS
2019-04-17 09:45:31 CLOSE_NOWRITE,CLOSE
2019-04-17 09:45:31 OPEN
2019-04-17 09:45:31 ACCESS
2019-04-17 09:45:31 ACCESS
2019-04-17 09:45:31 CLOSE_NOWRITE,CLOSE
2019-04-17 09:45:34 OPEN
2019-04-17 09:45:34 CLOSE_NOWRITE,CLOSE
2019-04-17 09:45:34 ATTRIB
2019-04-17 09:45:34 DELETE_SELF

The first series is me opening the file in vis, three seconds later I save the file. From the manpage about the delete_self event:

A watched file or directory was deleted. After this event the file or directory is no longer being watched. Note that this event can occur even if it is not explicitly being listened for.

It seems vis deletes the file, replacing it with a new one. This causes inotify (and probably kqueue, the other backend of entr) to stop listening.

@ninewise
Copy link
Collaborator

I recall some discussion about this in which was stated why this is how vis works, but I can't find the relative issue.

@ghost
Copy link

ghost commented Apr 19, 2019

It should work if you put this in your visrc.lua:

vis.events.subscribe(vis.events.WIN_OPEN, function(win)
	vis:command'set savemethod inplace'
end)

@geekdrive
Copy link
Author

geekdrive commented Apr 19, 2019

Using savemethod inplace fixes the problem. Thanks.

Please note that savemethod has to be in the WIN_OPEN event, it does not work if you put it under INIT (which I had tried previously). I kinda assumed that putting under INIT, that would make it the default (like some of the other settings) but anyway.

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

No branches or pull requests

2 participants