[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

insert-file-contents with replace option

From: James Clark
Subject: insert-file-contents with replace option
Date: Thu, 13 Nov 2003 17:43:23 +0700

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)

(defun my-bug ()
  (setq my-changes nil)
  (find-file "jjc-file")
  (insert "foobar")
  (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)
  (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]