all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Qiantan Hong <qhong@mit.edu>
To: Tassilo Horn <tsdh@gnu.org>, Eli Zaretskii <eliz@gnu.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: LOCK-BUFFER when two buffer visits the same buffer
Date: Sat, 11 Dec 2021 12:06:09 +0000	[thread overview]
Message-ID: <DE474B6F-95B2-4D90-9B8F-4BF16D371897@mit.edu> (raw)
In-Reply-To: <875yrv74hk.fsf@gnu.org>

> 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	other threads:[~2021-12-11 12:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-11 10:00 LOCK-BUFFER when two buffer visits the same buffer Qiantan Hong
2021-12-11 11:29 ` Tassilo Horn
2021-12-11 12:06   ` Qiantan Hong [this message]
2021-12-11 11:39 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DE474B6F-95B2-4D90-9B8F-4BF16D371897@mit.edu \
    --to=qhong@mit.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=tsdh@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.