emacs-devel
[Top][All Lists]
Advanced

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

Re: buffer-swap-text


From: Stefan Monnier
Subject: Re: buffer-swap-text
Date: Tue, 21 Oct 2008 18:04:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> > Should this function swap the value of buffer-file-coding-system as
>> > well?  Otherwise, we could confuse the user if the swapped text cannot
>> > be saved with the current buffer's encoding, and we will then pop up
>> > questions when the user tries to save.
>> I see buffer-swap-text as a (very) low-level function.  So, I'd
>> rather let the code that uses it deal with things like
>> buffer-file-coding-system.
> I cannot imagine a situation where code that uses this function would
> not want to copy buffer-file-coding-system.

>> I don't think we have enough experience with it to decide whether
>> that variable (or any other for that matter) needs to be swap
>> alongside the buffer's text.

> I'm okay with trying and erring like that, but I think that the only
> reason this didn't come up yet is because the 2 sole users of this
> function (tar-mode and pmail) swap text between a unibyte buffer and a
> multibyte buffer, and saving is allowed only from the unibyte one (and
> pmail is not yet used widely anyway).

Could be.  But I expect that 99.99% of the uses of buffer-swap-text will
follow this model.  Note also that the need to swap
buffer-file-coding-system depends on how the file is saved.

If the coding system to use is non-trivial, then writing the buffer-save
functionality might become far from obvious (since the save might query
the user about which coding-system to use, displaying the problematic
chars, but these are in the "other" buffer rather than the one normally
displayed), so I don't expect this use case to be common, and if it
comes up, we'll probably have much larger problems to deal with than
merely swapping buffer-file-coding-system.

Furthermore, I'd expect that swapping might not always be right: most
likely one of the two buffers will be a fresh new buffer, so swapping
would mean that the old buffer gets a buffer-file-coding-system set to
nil, which will be reflected in the modeline.


        Stefan




reply via email to

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