From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: James Clark Newsgroups: gmane.emacs.bugs Subject: insert-file-contents with replace option Date: Thu, 13 Nov 2003 17:43:23 +0700 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <1068720203.22548.13.camel@rambutan.bkk.thaiopensource.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1068720597 26180 80.91.224.253 (13 Nov 2003 10:49:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 13 Nov 2003 10:49:57 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Nov 13 11:49:55 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AKF2w-0003pm-00 for ; Thu, 13 Nov 2003 11:49:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AKG03-0001GG-WE for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Nov 2003 06:51:00 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AKFyz-00019D-Je for bug-gnu-emacs@gnu.org; Thu, 13 Nov 2003 06:49:53 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AKFyS-00016R-MT for bug-gnu-emacs@gnu.org; Thu, 13 Nov 2003 06:49:51 -0500 Original-Received: from [128.121.116.162] (helo=jclark.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AKFyS-00016I-3u for bug-gnu-emacs@gnu.org; Thu, 13 Nov 2003 06:49:20 -0500 Original-Received: from [192.168.0.148] ([203.172.98.94]) by jclark.com (8.12.10/8.11.2) with ESMTP id hADAlhOh062868 for ; Thu, 13 Nov 2003 03:47:49 -0700 (MST) Original-To: bug-gnu-emacs@gnu.org X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:6135 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:6135 insert-file-contents with a non-nil replace argument sometimes calls the after-change-functions with incorrect arguments. Here's some code that illustrates the problem: (defvar my-changes nil) (defun my-after-change (start end length) (setq my-changes (cons (list (buffer-size) start end length) my-changes))) (defun my-bug () (interactive) (setq my-changes nil) (find-file "jjc-file") (insert "foobar") (save-buffer) (delete-region (point-min) (point-max)) (insert "xyzzy") (add-hook 'after-change-functions 'my-after-change nil t) (insert-file-contents (buffer-file-name) nil nil nil t) (remove-hook 'after-change-functions 'my-after-change t) (save-buffer) (kill-buffer nil) (delete-file "jjc-file") (message "%S" (car my-changes))) If I do M-x my-bug, I get the message: (7 8 15 0) i.e. emacs has called the after change function with a start/end of 8/15 when the buffer size is 7. (With emacs -q I get (6 7 13 0).) This is on GNU/Linux, LANG=en_GB.UTF-8, with both Emacs 21.3 and Emacs from CVS on November 1. James