emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOCK-BUFFER when two buffer visits the same buffer


From: Qiantan Hong
Subject: Re: LOCK-BUFFER when two buffer visits the same buffer
Date: Sat, 11 Dec 2021 12:06:09 +0000

> lock-buffer doesn't support what you are evidently trying to do.  Its
> intended use is to prevent simultaneous modifications of a file by two
> users, or by a single user from two separate instances of Emacs.  You
> want reference counting (and probably also locking the file in the
> filesystem), and that isn't supported.
Figured that out, thanks. I could add reference counting myself,
but it probably doesn’t worth the effort at the moment.
The scenario comes up in the case of recursive transaction,
and guess I’ll just drop support for recursive transaction for now.

>> I do lock-buffer in the first buffer, then in the second buffer, and I
>> killed the second buffer, the lock is gone — even it seems that buffer
>> one should hold the lock!
> 
> More details, please.  Do you just call (lock-buffer) or (lock-buffer
> "~/file")?  One emacs instance or two?
It’s one Emacs instance.
I called (lock-buffer) after I set the buffer-file-truename of a temporary 
buffer.
In my case, (lock-buffer FILE) seems to make more sense, but I don’t
know how to unlock it. Therefore I just fake it with a temporary buffer
(so I can unlock it by doing (unlock-buffer) in that buffer later, or 
just kill it directly)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]