all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: buffer-swap-text
Date: Tue, 21 Oct 2008 18:04:32 -0400	[thread overview]
Message-ID: <jwvwsg11v14.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <uwsg2eziv.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 21 Oct 2008 17:30:48 +0200")

>> > 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	other threads:[~2008-10-21 22:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-21 10:42 buffer-swap-text Eli Zaretskii
2008-10-21 13:56 ` buffer-swap-text Stefan Monnier
2008-10-21 15:30   ` buffer-swap-text Eli Zaretskii
2008-10-21 22:04     ` Stefan Monnier [this message]
2008-10-21 19:40 ` buffer-swap-text Richard M. Stallman
2008-10-21 22:06   ` buffer-swap-text Stefan Monnier
2008-10-23  3:06     ` buffer-swap-text Richard M. Stallman
2008-10-23  3:24       ` buffer-swap-text Stefan Monnier
2008-10-23 21:09         ` buffer-swap-text Richard M. Stallman
2008-10-24  4:05           ` buffer-swap-text Stefan Monnier

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=jwvwsg11v14.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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.