unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* insert-file-contents with replace option
@ 2003-11-13 10:43 James Clark
  0 siblings, 0 replies; only message in thread
From: James Clark @ 2003-11-13 10:43 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-13 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-13 10:43 insert-file-contents with replace option James Clark

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).