all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Avoiding 'with-temp-buffer' in tight loops
Date: Sat, 10 Aug 2024 15:59:29 +0200	[thread overview]
Message-ID: <f7fbc518-fbb7-4a08-8623-60ff94c6134a@gmx.at> (raw)
In-Reply-To: <86mslmkmnv.fsf@gnu.org>

 >> Ever since 'substitute-command-keys' has been transferred to help.el,
 >> putting initial breakpoints in Fkill_buffer has become virtually
 >> impossible.
 >
 > It should be possible to make the breakpoint conditional on the first
 > character of a temporary buffer not being SPC.

This fails when investigating a general misbehavior of 'kill-buffer'
that might also happen when the buffer name starts with a space.  And it
won't catch the case where such a buffer is killed inadvertently as
"current buffer".

 > This needs to be amended to support several threads calling
 > substitute-command-keys, I think.

Protecting access to any such buffer with the help of a mutex should be
trivial.  But IIUC we don't do such a thing anywhere and it's certainly
not done with Vprin1_to_string_buffer which was used earlier for this
purpose.  So my faith in the correct resolution of locks is limited.

 > An alternative for the above is to have substitute-command-keys bind
 > some variable non-nil, and have a breakpoint be conditional on that
 > variable's value.  If this works, I think it's simpler and cleaner.

This means that every tight loop using 'with-temp-buffer' would have to
set up and clear that variable.  It would fail to catch all cases where
killing a buffer associated with that variable is the cause of the
problem to fix.

martin



  reply	other threads:[~2024-08-10 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-09  8:30 Avoiding 'with-temp-buffer' in tight loops martin rudalics
2024-08-09 10:36 ` Eli Zaretskii
2024-08-10 13:59   ` martin rudalics [this message]
2024-08-10 14:11     ` Eli Zaretskii
2024-08-12  7:51       ` martin rudalics
2024-08-12 10:55         ` 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=f7fbc518-fbb7-4a08-8623-60ff94c6134a@gmx.at \
    --to=rudalics@gmx.at \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@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.