unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
Cc: Takaaki.Ota@am.sony.com, emacs-devel@gnu.org
Subject: Re: save-buffer in tar-mode
Date: Thu, 12 Feb 2004 22:04:57 +0900 (JST)	[thread overview]
Message-ID: <200402121304.WAA11159@etlken.m17n.org> (raw)
In-Reply-To: <E1Aq7t5-0005ip-4d@fencepost.gnu.org> (message from Richard Stallman on Mon, 09 Feb 2004 04:39:31 -0500)

In article <E1Aq7t5-0005ip-4d@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     Yes.  tar-mode toggles enable-multibyte-characters on saving
>     a file by set-buffer-multibyte and that function discards
>     undo info.  To fix it, we must record this toggling in
>     buffer-undo-list.

> That is one way to fix it.  Another way would be to avoid changing
> enable-multibyte-characters.  The reason for doing so is to control
> how insert-buffer copies the text.  This suggests that the cleanest
> approach is to define a new primitive that does exactly the kind of
> copying that is desired.  I think that should be easy.

To avoid changing enable-multibyte-characters, I have
another idea.

Currently, on saving a file contained in a tar file, we
toggle multibyteness twice for both the file buffer and the
tar file buffer (very inefficient).  The reason for toggling
in the tar file buffer is that operations based on the tar
information work only in unibyte buffer.  And, why that
operations are so is that we don't have a primitive of
making buffer multibyte like the same way as
string-to-multibyte.  I proposed to have the same kind of
primitive for a buffer long ago, but at that time, it was
rejected.

I'd like to propose it again, i.e., make
set-buffer-multibyte accept `to' as FLAG.
(set-buffer-multibyte 'to) is exactly the same as:
(let ((str (string-to-multibyte (buffer-string))))
   (erase-buffer)
   (set-buffer-multibyte t)
   (insert str))     

Then, after we read the tar file by `no-conversion', we can
make the buffer multibyte by `to'.  After that, we never
have to change the multibyteness.

> I agree that it would be cleaner if set-buffer-multibyte did not
> destroy the undo list.  In principle it certainly ought to preserve
> the undo list.  But I think that could be a lot of work, too much
> to be worth the trouble.

> However, the judgment that it was too much trouble was in Emacs 20 or
> so.  Since then we have made substantial changes in how multibyte
> encoding works.  Maybe now it is not so hard.  By all means think
> about it.

> I don't think that the planned new extension to undo-list format will
> help.  That could be useful for recording the set-buffer-multibyte
> operation, so that it can be undone.  However, the real problem is to
> update the existing undo-list entries so that they still make sense.
> The new kind of undo entry won't help with that.

I don't understand why we have to update the existing
undo-list entries.  Each of them make sense in each
multibyte state.  So, as far as undo recovers multibyteness,
they always make sense when they are referred.

> Meanwhile, even if set-buffer-multibyte is fixed to correct the undo
> list, the other solution (a new copy operation) would be a better way
> to do this operation.

The new copy operation can be simulated by something like
this:

(defun new-insert-buffer (buf)
   (let ((str (save-execursion (set-buffer buf) (buffer-string))))
     (insert (if enable-multibyte-characters 
		 (string-as-multibyte str)
	       (string-as-unibyte str)))))

As it may be useful for the other case, I don't have strong
objection for having such primitive.  But, for tar-mode, I
think the one I proposed at the head is better.

---
Ken'ichi HANDA
handa@m17n.org

  reply	other threads:[~2004-02-12 13:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-04 21:50 save-buffer in tar-mode Tak Ota
2004-02-04 23:36 ` Kenichi Handa
2004-02-04 23:53   ` Tak Ota
2004-02-05  2:17     ` Kenichi Handa
2004-02-05  2:54       ` Stefan Monnier
2004-02-09  9:39 ` Richard Stallman
2004-02-12 13:04   ` Kenichi Handa [this message]
2004-02-12 17:12     ` Stefan Monnier
     [not found]       ` <200403021222.VAA17913@etlken.m17n.org>
2004-03-03 15:18         ` Richard Stallman
2004-03-03 22:32           ` Stefan Monnier
2004-03-05 12:15             ` Richard Stallman
2004-02-13 17:35     ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=200402121304.WAA11159@etlken.m17n.org \
    --to=handa@m17n.org \
    --cc=Takaaki.Ota@am.sony.com \
    --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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).