Gnus development mailing list
 help / color / mirror / Atom feed
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: decode-coding-region
Date: 04 Sep 1998 14:09:20 +0200	[thread overview]
Message-ID: <kig90k0m64v.fsf@jagor.srce.hr> (raw)
In-Reply-To: Lars Magne Ingebrigtsen's message of "03 Sep 1998 22:44:31 +0200"

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Hrvoje Niksic <hniksic@srce.hr> writes:
> 
> > FYI, decode-coding-region and encode-coding-region also thrash the
> > extents under XEmacs.  If you need a workaround for that, please let
> > me know.
> 
> It would be nice to preserve the extents.

You might want to try something like this until we fix the primitives:

(defmacro gnus-xmas-preserve-extents (&rest body)
  (let ((extents (gensym "extents-")))
    `(let (,extents)
       (map-extents (lambda (extent ignored)
		      (push (list extent
				  (extent-start-position extent)
				  (extent-end-position extent))
			    ,extents)
		      (detach-extent extent)
		      nil)
		    buffer start end)
       ,@body
       (dolist (extent ,extents)
	 (set-extent-endpoints (first extent) (second extent) (third extent))))))

(defun gnus-xmas-decode-coding-region (start end coding-system &optional buffer)
  "Like decode-coding-region, but preserves extents."
  (gnus-xmas-preserve-extents
   (decode-coding-region start end coding-system buffer)))

(defun gnus-xmas-encode-coding-region (start end coding-system &optional buffer)
  "Like encode-coding-region, but preserves extents."
  (gnus-xmas-preserve-extents
   (encode-coding-region start end coding-system buffer)))

However, this will fail to work correctly when the decoding changes
the number of characters, because the extent indices will not be
preserved correctly.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Thou Who might be our Father Who perhaps may be in Heaven...
                                                -- Roger Zelazny


  reply	other threads:[~1998-09-04 12:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-03 14:56 decode-coding-region Hrvoje Niksic
1998-09-03 20:44 ` decode-coding-region Lars Magne Ingebrigtsen
1998-09-04 12:09   ` Hrvoje Niksic [this message]
1998-09-04 15:41     ` decode-coding-region Lars Magne Ingebrigtsen
1998-09-04 16:49       ` decode-coding-region Hrvoje Niksic

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=kig90k0m64v.fsf@jagor.srce.hr \
    --to=hniksic@srce.hr \
    /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.
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 NNTP newsgroup(s).