all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
Cc: bug-gnu-emacs@gnu.org, XEmacs Beta <xemacs-beta@xemacs.org>,
	xemacs-patches@xemacs.org
Subject: Re: Buffer corruption with jka-compr.el and revert-buffer
Date: Mon, 26 May 2003 18:36:27 +0900	[thread overview]
Message-ID: <87y90ujbhg.fsf@tleepslib.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <16081.44010.668903.197750@martin.meltin.net> (Martin Schwenke's message of "Mon, 26 May 2003 15:53:46 +1000")

Thanks for your report, Martin.

>>>>> "Martin" == Martin Schwenke <martin@meltin.net> writes:

    Martin> I've had a look at revert-buffer and nothing jumps out.
    Martin> I've also had a look at jka-compr.el and I've run away
    Martin> screaming...  I suspect it would be a lot simpler without
    Martin> all that coding system stuff...  :-)

The REPLACE semantics of j-c-insert-file-contents were simply wrong.

This fixes that, and a couple of minor bugs like the truncated
argument list and the missing docstring.  It's not really ready for
prime time; see the #### comments.  However, it's strictly better than
the existing code in XEmacs, and jka-compr will probably be obsolete
in XEmacs 21.5.

Caveat Emacsers.  I have no idea whether this is correct for GNU Emacs.

Index: xemacs-packages/os-utils/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/ChangeLog,v
retrieving revision 1.38
diff -u -U0 -r1.38 ChangeLog
--- xemacs-packages/os-utils/ChangeLog	21 Mar 2003 05:51:13 -0000	1.38
+++ xemacs-packages/os-utils/ChangeLog	26 May 2003 09:24:01 -0000
@@ -0,0 +1,5 @@
+2003-05-26  Stephen J. Turnbull  <stephen@xemacs.org>
+
+	* jka-compr.el (jka-compr-insert-file-contents): New docstring.
+	Implement REPLACE argument correctly.
+

Index: xemacs-packages/os-utils/jka-compr.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/jka-compr.el,v
retrieving revision 1.8
diff -u -r1.8 jka-compr.el
--- xemacs-packages/os-utils/jka-compr.el	27 Mar 2000 13:11:15 -0000	1.8
+++ xemacs-packages/os-utils/jka-compr.el	26 May 2003 09:24:08 -0000
@@ -517,7 +517,31 @@
 					  )))))
 
 
-(defun jka-compr-insert-file-contents (file &optional visit beg end replace)
+;; #### Should error or warn if the ignore-me arguments are supplied.
+(defun jka-compr-insert-file-contents (file &optional visit beg end replace
+				       ignore-me ignore-me-too)
+  "Insert contents of FILE in current buffer after point.
+Returns list of absolute file name and length of data inserted.
+
+If second argument VISIT is non-nil, the buffer's visited filename
+and last save file modtime are set, and it is marked unmodified.
+If visiting and the file does not exist, visiting is completed
+before the error is signaled.
+
+The optional third and fourth arguments START and END
+specify what portion of the file to insert.
+If VISIT is non-nil, START and END must be nil.
+If optional fifth argument REPLACE is non-nil,
+it means replace the current buffer contents (in the accessible portion)
+with the file contents.  This is better than simply deleting and inserting
+the whole thing because (1) it preserves some marker positions
+and (2) it puts less data in the undo list.  (#### Is (2) true?)
+
+Coding system arguments are completely ignored (see documentation of the
+6th and 7th arguments to `insert-file-contents').  The coding system is set
+to 'undecided unless `coding-system-for-read' is bound.  WARNING: That means
+this function is badly broken under Mule.  Use jka-compr at your own risk
+in Mule Emacsen."
   (barf-if-buffer-read-only)
 
   (and (or beg end)
@@ -571,7 +594,7 @@
 
 		    (progn
 		      (if replace
-			  (goto-char (point-min)))
+			  (delete-region (point-min) (point-max)))
 		      (setq start (point))
 		      (if (or beg end)
 			  (jka-compr-partial-uncompress uncompress-program
@@ -595,12 +618,6 @@
 						  t
 						  nil
 						  uncompress-args)))
-		      (setq size (- (point) start))
-		      (if replace
-			  (let* ((del-beg (point))
-				 (del-end (+ del-beg size)))
-			    (delete-region del-beg
-					   (min del-end (point-max)))))
 		      (goto-char start))
 		  (error
 		   (if (and (eq (car error-code) 'file-error)



-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.



  reply	other threads:[~2003-05-26  9:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-26  5:53 Buffer corruption with jka-compr.el and revert-buffer Martin Schwenke
2003-05-26  9:36 ` Stephen J. Turnbull [this message]
2003-05-26 23:50   ` Martin Schwenke
2003-05-27  6:28     ` Martin Schwenke

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=87y90ujbhg.fsf@tleepslib.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=bug-gnu-emacs@gnu.org \
    --cc=xemacs-beta@xemacs.org \
    --cc=xemacs-patches@xemacs.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.