Hi everyone. I’m having a bit of trouble with PCEmacs. In short, when I edit a
file it immediately pops up a dialog saying the file has been modified and
asking me whether to reload it. I give more details below, but this is a bit
dangerous because if I accidentally press “Reload” I risk losing work.
Here are some more details on what happens and how to reproduce it, at least
on my system. I’m running SWI 9.1.1, 64-bit on Windows 11.
Note that the same happens if you type any key instead of Enter.
I first noticed this happening around 23 September this year, when I got a new
laptop with Windows 11 on it (I know). I downloaded the latest SWI-Prolog
version, but I’m not sure which version that was. I have a couple of left-over
installers on my machine and the earliest is swipl-9.0.2-1.x64.exe.
I went back to version 8.4.3 (64 bit for windows) and I don’t get the same
thing. No reload dialog pops up when I edit a PCEMacs buffer after calling
make/0.
If this is correct behaviour, is there a way to set a flag or something else
to turn it off?
It is rather unclear where this comes from. Others? The behavior is defined in buffer.pl, which you can find after starting PceEmacs and than run
?- edit(_->check_modified_file).
Which should get you at
check_modified_file(B, Frame:frame=[frame], Confirm:confirm=[bool]) :->
"Check if file has been modified after buffer"::
( get(B, file, File),
File \== @nil,
send(File, exists),
get(B, time_stamp, Stamp),
get(File, time, FileStamp),
\+ send(Stamp, equal, FileStamp),
\+ object(@emacs_reverting)
-> ( confirm_reload(B, Frame, Confirm, File)
-> send(B, revert)
; true
)
; true
).
Possibly some print statements will help figuring out what is wrong. You can also try playing around with the file object, e.g.
?- new(F, file('c:/users/[REDACTED]/pcemacs_test.pl')).
?- get($F, time, Time).
...
etc. Possibly that reveals what is wrong. Any weird (non-ASCII) characters in [REDACTED]? Some things have changed to the low-level API to the filesystem on Windows.
One thing that often bites on atypical filesystems is case-(in)sensitivity. For example, what would happen had the original file name really been “Buffer.pl” ?
That is a hint. It would be a bit odd if you can read and write the file, but cannot get its time stamp. Try using the xpce class file on the target file.
That is normal. Considering the modification times left by the installer it is quite likely it considers the indexes out of date, but if it can’t write them anyway it doesn’t bother. When you run as admin it should do this update once.
Note that you first need to start the editor to get this code loaded. Next, this should work.
Unfortunately, I think this was a false guess on my part. I was not following the steps I documented above exactly, so I got confused. If I follow those steps exactly, my admin account does pop up the “Reload” dialog.
I get this update more than once, I think maybe two or three times after I uninstall and reinstall.
Btw, there’s a message about updating xpce/prolog/lib also, I edited my post on discord after you’ve read it probably.
Yes, I first open my pcemacs_test.pl file in PCEmacs, then I try edit(_->check_modified_file)., but what opens is a blank file titled buffer.pl.
If I call edit(buffer.pl) PCEmacs opens the right buffer.pl, but I can’t seem to get it to find the send method.
Thanks! But “Controlled folder access” is set to off on my user account. And I think the permissions thing was a red herring after all.
I can tell that the SWI uninstaller is leaving behind some files, e.g. the console history. Is there a way to really remove everything, as if SWI had never been installed on a machine?
I’m asking because I don’t understand e.g. why I cant edit check_modified_file directly anymore. This morning, just before I tried changing the capitalisation of its file name I could, but now I can’t, even after having uninstalled and re-installed swi multiple times. There must be something that remains in memory and messes things up at least for that (and probably nothing to do with my main issue).
I tried deleting some registry keys manually but I’m not sure I got everything. What else should I remove? I want to try and make a clean install, as much as possible (since this is windows and it just has to go and put things where you’ll never find them grumble).
Well, the method is there, and if it is no longer you must have messed up something … It is a bit hard to guess what from here
Bottom line on what it does is that it maintains a time_stamp slot on the buffer from the last load or save. If the buffer goes from unmodified to modified (first modification) it validates this stamp to the time it gets from the file object. Both use file<-time, which returns a date object that contains the POSIX time stamp (seconds after 1970). The two are compared using date->equal. Something must be going wrong there. Either some permission/file system issue that returns bogus values or some precision issue that makes it return slightly different values that do not compare equal.
I can’t reproduce this, neither on Wine, nor on Windows 11 in a VM.
Version 8.5.15 was last version without this bug, later versions all have it.
The xpce is too difficult for me, I have spent many many evenings to get a grip of xpce and the bug, I have given up.
I think this commit made the bug, I have build swipl-devel versions 8.5.16 release version and used only those commits before this commit. They are the same commit.
Thanks. That resolves the issue. the file<-time method used to return the modification time by default, but this commit effectively changed the default to access time on Windows. Pushed a fix, so the source should be fine and tomorrow’s daily build should have this fixed.