emacs-devel
[Top][All Lists]
Advanced

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

Re: master 048e72a403e 1/2: Add file/buffer-to-register (Bug#73308)


From: Barra Ó Catháin
Subject: Re: master 048e72a403e 1/2: Add file/buffer-to-register (Bug#73308)
Date: Mon, 07 Oct 2024 00:21:28 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

D'oh! You're absolutely correct. I've attached a patch containing a fix
for exactly this; It adds a check to see if buffer is currently alive,
and uses with-current-buffer to ensure that it's adding to the correct
one. Let me know if I should send this somewhere else; I'm still
learning mailing list development etiquette.

Attachment: 0001-Fix-buffer-to-register-add-hook.patch
Description: Text Data

Thanks for the catch!
-----
Barra

Eshel Yaron <me@eshelyaron.com> writes:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>> branch: master
>> commit 048e72a403e22dc394b265c6ff290b8d40e806a5
>> Author: Barra Ó Catháin <barra@ocathain.ie>
>> Commit: Eli Zaretskii <eliz@gnu.org>
>>
>>     Add file/buffer-to-register (Bug#73308)
>
> [...]
>
>> +(defun buffer-to-register (buffer register)
>> +  "Insert BUFFER into REGISTER.
>> +To visit the buffer, use \\[jump-to-register].
>> +
>> +Interactively, prompt for REGISTER using `register-read-with-preview'.
>> +With a prefix-argument, prompt for BUFFER-NAME using `read-buffer',
>> +With no prefix-argument, use the current buffer for BUFFER."
>> +  (interactive (list (if (eq current-prefix-arg nil)
>> +                         (current-buffer)
>> +                       (read-buffer "Buffer: "))
>> +                     (register-read-with-preview "Buffer to register: ")))
>> +  (add-hook 'kill-buffer-hook 'register-buffer-to-file-query nil t)
>> +  (set-register register (cons 'buffer buffer)))
>
> Hmm, this looks like a subtle bug: the BUFFER argument can be any
> buffer, but the add-hook call is always local to the current buffer.
> Shouldn't that add-hook happen inside a with-current-buffer or something
> like that?
>
>
> Best,
>
> Eshel

reply via email to

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