[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: insert-file-contents and format-decode
From: |
Richard Stallman |
Subject: |
Re: insert-file-contents and format-decode |
Date: |
Tue, 03 Jul 2007 00:24:35 -0400 |
! (let (value size old-undo)
! ;; Record only one undo entry for the insertion. Inhibit
point-motion and
! ;; modification hooks as with `insert-file-contents'.
! (let ((inhibit-point-motion-hooks t)
! (inhibit-modification-hooks t))
! ;; Don't bind `buffer-undo-list' to t here to assert that
! ;; `insert-file-contents' may record whether the buffer was
unmodified
! ;; before.
! (let ((format-alist nil))
! (setq value (insert-file-contents filename nil beg end))
! (setq size (nth 1 value)))
! (when (consp buffer-undo-list)
! (let ((head (car buffer-undo-list)))
! (when (and (consp head)
! (equal (car head) (point))
! (equal (cdr head) (+ (point) size)))
! ;; Remove first entry from `buffer-undo-list', we shall insert
! ;; another one below.
! (setq old-undo (cdr buffer-undo-list)))))
That pateh is basically good, but it could be simpler. Instead of
letting insert-file-contents produce an undo entry and taking it off
and taking it apart, it would be better to inhibit undo around
insert-file-contents and generate the undo entry from scratch in all
cases. When no format decoding is done, VALUE has the size you need.