* reverting buffer from non-existent file
@ 2006-02-06 7:00 Martin Rudalics
2006-02-07 6:06 ` Richard M. Stallman
0 siblings, 1 reply; 6+ messages in thread
From: Martin Rudalics @ 2006-02-06 7:00 UTC (permalink / raw)
When reverting a buffer and the file to revert from is not or no more
readable, all undo information gets killed nevertheless. This is an
unhappy effect because I occasionally forget that I have not yet saved a
buffer I just created, do `revert-buffer', and loose the entire
information needed to undo the latest changes. The patch below fixes
the problem for me.
============================================================
*** files.el Wed Feb 1 10:17:44 2006
--- files.el Fri Feb 3 20:47:02 2006
***************
*** 3840,3845 ****
--- 3840,3848 ----
(setq buffer-backed-up nil))
;; Get rid of all undo records for this buffer.
(or (eq buffer-undo-list t)
+ ;; Do not clear buffer-undo-list if reverting will fail.
+ (and (not (file-readable-p file-name))
+ (not revert-buffer-insert-file-contents-function))
(setq buffer-undo-list nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
***************
*** 3847,3863 ****
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
after-revert-hook)))
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (if revert-buffer-insert-file-contents-function
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)
! (if (not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
;; Bind buffer-file-name to nil
;; so that we don't try to lock the file.
(let ((buffer-file-name nil))
--- 3850,3873 ----
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
after-revert-hook)))
! (cond
! (revert-buffer-insert-file-contents-function
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)))
! ((not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! ((not (file-readable-p file-name))
! (error "File %s is not readable" file-name))
! (t
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
;; Bind buffer-file-name to nil
;; so that we don't try to lock the file.
(let ((buffer-file-name nil))
***************
*** 3865,3871 ****
(unlock-buffer)))
(widen)
(let ((coding-system-for-read
! ;; Auto-saved file shoule be read by Emacs'
;; internal coding.
(if auto-save-p 'auto-save-coding
(or coding-system-for-read
--- 3875,3881 ----
(unlock-buffer)))
(widen)
(let ((coding-system-for-read
! ;; Auto-saved file should be read by Emacs'
;; internal coding.
(if auto-save-p 'auto-save-coding
(or coding-system-for-read
***************
*** 3881,3887 ****
(insert-file-contents file-name (not auto-save-p)
nil nil t))
(insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
--- 3891,3897 ----
(insert-file-contents file-name (not auto-save-p)
nil nil t))
(insert-file-contents file-name (not auto-save-p)
! nil nil t))))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
============================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reverting buffer from non-existent file
2006-02-06 7:00 reverting buffer from non-existent file Martin Rudalics
@ 2006-02-07 6:06 ` Richard M. Stallman
2006-02-07 9:44 ` martin rudalics
2006-02-07 15:31 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Richard M. Stallman @ 2006-02-07 6:06 UTC (permalink / raw)
Cc: emacs-devel
Thanks for fixing this problem. I think it is cleaner to bind
buffer-read-only and buffer-undo-list only once. Would you
please make that small alteration, then send the revised change
plus a suitable change log entry? They we will install it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reverting buffer from non-existent file
2006-02-07 6:06 ` Richard M. Stallman
@ 2006-02-07 9:44 ` martin rudalics
2006-02-07 15:31 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: martin rudalics @ 2006-02-07 9:44 UTC (permalink / raw)
Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 505 bytes --]
> I think it is cleaner to bind
> buffer-read-only and buffer-undo-list only once.
On the one hand I don't want to compromise the original behavior for
`revert-buffer-insert-file-contents-function' non-nil. On the other I
don't want to bind `buffer-undo-list' when generating the "File no
longer exists ..." errors. With `debug-on-error' non-nil, switching to
*Backtrace* would leave me without undo information again. Hence the -
admittedly ugly - two bindings. I added a comment to explain this.
[-- Attachment #2: files-patch --]
[-- Type: text/plain, Size: 4433 bytes --]
* files.el (revert-buffer): Do not discard undo list when buffer
cannot be reverted because file does not exist.
*** files.el Wed Feb 1 10:17:44 2006
--- files.el Tue Feb 7 10:32:00 2006
***************
*** 3815,3821 ****
buffer-auto-save-file-name
(file-readable-p buffer-auto-save-file-name)
(y-or-n-p
! "Buffer has been auto-saved recently. Revert from auto-save file? ")))
(file-name (if auto-save-p
buffer-auto-save-file-name
buffer-file-name)))
--- 3815,3821 ----
buffer-auto-save-file-name
(file-readable-p buffer-auto-save-file-name)
(y-or-n-p
! "Buffer has been auto-saved recently. Revert from auto-save file? ")))
(file-name (if auto-save-p
buffer-auto-save-file-name
buffer-file-name)))
***************
*** 3840,3845 ****
--- 3840,3848 ----
(setq buffer-backed-up nil))
;; Get rid of all undo records for this buffer.
(or (eq buffer-undo-list t)
+ ;; Do not clear buffer-undo-list if reverting will fail.
+ (and (not (file-readable-p file-name))
+ (not revert-buffer-insert-file-contents-function))
(setq buffer-undo-list nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
***************
*** 3847,3863 ****
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
after-revert-hook)))
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (if revert-buffer-insert-file-contents-function
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)
! (if (not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
;; Bind buffer-file-name to nil
;; so that we don't try to lock the file.
(let ((buffer-file-name nil))
--- 3850,3876 ----
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
after-revert-hook)))
! (cond
! (revert-buffer-insert-file-contents-function
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)))
! ;; Don't bind buffer-undo-list around the error reporting
! ;; clauses to avoid that undo information gets lost when
! ;; calling the debugger.
! ((not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! ((not (file-readable-p file-name))
! (error "File %s is not readable" file-name))
! (t
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
;; Bind buffer-file-name to nil
;; so that we don't try to lock the file.
(let ((buffer-file-name nil))
***************
*** 3865,3871 ****
(unlock-buffer)))
(widen)
(let ((coding-system-for-read
! ;; Auto-saved file shoule be read by Emacs'
;; internal coding.
(if auto-save-p 'auto-save-coding
(or coding-system-for-read
--- 3878,3884 ----
(unlock-buffer)))
(widen)
(let ((coding-system-for-read
! ;; Auto-saved file should be read by Emacs'
;; internal coding.
(if auto-save-p 'auto-save-coding
(or coding-system-for-read
***************
*** 3881,3887 ****
(insert-file-contents file-name (not auto-save-p)
nil nil t))
(insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
--- 3894,3900 ----
(insert-file-contents file-name (not auto-save-p)
nil nil t))
(insert-file-contents file-name (not auto-save-p)
! nil nil t))))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reverting buffer from non-existent file
2006-02-07 6:06 ` Richard M. Stallman
2006-02-07 9:44 ` martin rudalics
@ 2006-02-07 15:31 ` Stefan Monnier
2006-02-07 19:27 ` martin rudalics
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2006-02-07 15:31 UTC (permalink / raw)
Cc: Martin Rudalics, emacs-devel
> Thanks for fixing this problem. I think it is cleaner to bind
> buffer-read-only and buffer-undo-list only once. Would you
> please make that small alteration, then send the revised change
> plus a suitable change log entry? They we will install it.
While we're here:
- it's probably better to bind inhibit-read-only than buffer-read-only.
- IIRC buffer-undo-list doesn't need to be bound here since
insert-file-contents does it for us anyway.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reverting buffer from non-existent file
2006-02-07 15:31 ` Stefan Monnier
@ 2006-02-07 19:27 ` martin rudalics
2006-02-10 8:45 ` martin rudalics
0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2006-02-07 19:27 UTC (permalink / raw)
Cc: rms, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
> - it's probably better to bind inhibit-read-only than buffer-read-only.
> - IIRC buffer-undo-list doesn't need to be bound here since
> insert-file-contents does it for us anyway.
In the attached patch I followed your suggestions and also simplified
the `revert-without-query' mechanism slightly. By the way, shouldn't
(set (make-local-variable 'revert-buffer-internal-hook)
local-hook)
be handled by add-hook?
[-- Attachment #2: files-patch --]
[-- Type: text/plain, Size: 6718 bytes --]
*** files.el Wed Feb 1 10:17:44 2006
--- files.el Tue Feb 7 20:23:42 2006
***************
*** 3791,3803 ****
confirmation.)
Optional third argument PRESERVE-MODES non-nil means don't alter
! the files modes. Normally we reinitialize them using `normal-mode'.
If the value of `revert-buffer-function' is non-nil, it is called to
do all the work for this command. Otherwise, the hooks
`before-revert-hook' and `after-revert-hook' are run at the beginning
and the end, and if `revert-buffer-insert-file-contents-function' is
! non-nil, it is called instead of rereading visited file contents."
;; I admit it's odd to reverse the sense of the prefix argument, but
;; there is a lot of code out there which assumes that the first
--- 3791,3803 ----
confirmation.)
Optional third argument PRESERVE-MODES non-nil means don't alter
! the file's modes. Normally we reinitialize them using `normal-mode'.
If the value of `revert-buffer-function' is non-nil, it is called to
do all the work for this command. Otherwise, the hooks
`before-revert-hook' and `after-revert-hook' are run at the beginning
and the end, and if `revert-buffer-insert-file-contents-function' is
! non-nil, it is called instead of rereading the visited file's contents."
;; I admit it's odd to reverse the sense of the prefix argument, but
;; there is a lot of code out there which assumes that the first
***************
*** 3823,3835 ****
(error "Buffer does not seem to be associated with any file"))
((or noconfirm
(and (not (buffer-modified-p))
! (let ((tail revert-without-query)
! (found nil))
! (while tail
! (if (string-match (car tail) file-name)
! (setq found t))
! (setq tail (cdr tail)))
! found))
(yes-or-no-p (format "Revert buffer from file %s? "
file-name)))
(run-hooks 'before-revert-hook)
--- 3823,3832 ----
(error "Buffer does not seem to be associated with any file"))
((or noconfirm
(and (not (buffer-modified-p))
! (catch 'found
! (dolist (regexp revert-without-query)
! (when (string-match regexp file-name)
! (throw 'found t)))))
(yes-or-no-p (format "Revert buffer from file %s? "
file-name)))
(run-hooks 'before-revert-hook)
***************
*** 3838,3887 ****
(and (not auto-save-p)
(not (verify-visited-file-modtime (current-buffer)))
(setq buffer-backed-up nil))
- ;; Get rid of all undo records for this buffer.
- (or (eq buffer-undo-list t)
- (setq buffer-undo-list nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
(let ((global-hook (default-value 'after-revert-hook))
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
! after-revert-hook)))
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (if revert-buffer-insert-file-contents-function
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)
! (if (not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! ;; Bind buffer-file-name to nil
! ;; so that we don't try to lock the file.
! (let ((buffer-file-name nil))
! (or auto-save-p
! (unlock-buffer)))
! (widen)
! (let ((coding-system-for-read
! ;; Auto-saved file shoule be read by Emacs'
! ;; internal coding.
! (if auto-save-p 'auto-save-coding
! (or coding-system-for-read
! buffer-file-coding-system-explicit))))
! ;; This force after-insert-file-set-coding
! ;; (called from insert-file-contents) to set
! ;; buffer-file-coding-system to a proper value.
! (kill-local-variable 'buffer-file-coding-system)
!
! ;; Note that this preserves point in an intelligent way.
! (if preserve-modes
! (let ((buffer-file-format buffer-file-format))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
--- 3835,3886 ----
(and (not auto-save-p)
(not (verify-visited-file-modtime (current-buffer)))
(setq buffer-backed-up nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
(let ((global-hook (default-value 'after-revert-hook))
(local-hook-p (local-variable-p 'after-revert-hook))
(local-hook (and (local-variable-p 'after-revert-hook)
! after-revert-hook))
! (inhibit-read-only t))
! (cond
! (revert-buffer-insert-file-contents-function
! (unless (eq buffer-undo-list t)
! ;; Get rid of all undo records for this buffer.
! (setq buffer-undo-list nil))
! ;; Don't make undo records for the reversion.
! (let ((buffer-undo-list t))
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)))
! ((not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! (t
! ;; Bind buffer-file-name to nil
! ;; so that we don't try to lock the file.
! (let ((buffer-file-name nil))
! (or auto-save-p
! (unlock-buffer)))
! (widen)
! (let ((coding-system-for-read
! ;; Auto-saved file should be read by Emacs'
! ;; internal coding.
! (if auto-save-p 'auto-save-coding
! (or coding-system-for-read
! buffer-file-coding-system-explicit))))
! ;; This force after-insert-file-set-coding
! ;; (called from insert-file-contents) to set
! ;; buffer-file-coding-system to a proper value.
! (kill-local-variable 'buffer-file-coding-system)
!
! ;; Note that this preserves point in an intelligent way.
! (if preserve-modes
! (let ((buffer-file-format buffer-file-format))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: reverting buffer from non-existent file
2006-02-07 19:27 ` martin rudalics
@ 2006-02-10 8:45 ` martin rudalics
0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics @ 2006-02-10 8:45 UTC (permalink / raw)
Cc: emacs-devel, Stefan Monnier, rms
[-- Attachment #1: Type: text/plain, Size: 272 bytes --]
> ... shouldn't
>
> (set (make-local-variable 'revert-buffer-internal-hook)
> local-hook)
>
> be handled by add-hook?
My mind was wandering, please disregard that. I now also modified
recover-file to use inhibit-read-only and fixed some doc-strings.
[-- Attachment #2: files-patch --]
[-- Type: text/plain, Size: 9256 bytes --]
* files.el (revert-buffer, recover-file): Replace
buffer-read-only by inhibit-read-only.
Suggested by Stefan Monnier.
(revert-buffer): Let insert-file-contents discard
buffer-undo-list. Simplify code.
(find-file, find-file-existing, revert-buffer): Doc-string fixes.
*** files.el Wed Feb 1 10:17:44 2006
--- files.el Fri Feb 10 08:22:16 2006
***************
*** 1024,1030 ****
Interactively, or if WILDCARDS is non-nil in a call from Lisp,
expand wildcards (if any) and visit multiple files. You can
! suppress wildcard expansion by setting `find-file-wildcards'.
To visit a file without any kind of conversion and without
automatically choosing a major mode, use \\[find-file-literally]."
--- 1024,1030 ----
Interactively, or if WILDCARDS is non-nil in a call from Lisp,
expand wildcards (if any) and visit multiple files. You can
! suppress wildcard expansion by setting `find-file-wildcards' to nil.
To visit a file without any kind of conversion and without
automatically choosing a major mode, use \\[find-file-literally]."
***************
*** 1076,1082 ****
(defun find-file-existing (filename &optional wildcards)
"Edit the existing file FILENAME.
! Like \\[find-file] but only allow files that exists."
(interactive (find-file-read-args "Find existing file: " t))
(unless (file-exists-p filename) (error "%s does not exist" filename))
(find-file filename wildcards)
--- 1076,1082 ----
(defun find-file-existing (filename &optional wildcards)
"Edit the existing file FILENAME.
! Like \\[find-file] but only allow a file that exists."
(interactive (find-file-read-args "Find existing file: " t))
(unless (file-exists-p filename) (error "%s does not exist" filename))
(find-file filename wildcards)
***************
*** 3787,3794 ****
to nil.
Optional second argument NOCONFIRM means don't ask for confirmation at
! all. (The local variable `revert-without-query', if non-nil, prevents
! confirmation.)
Optional third argument PRESERVE-MODES non-nil means don't alter
the files modes. Normally we reinitialize them using `normal-mode'.
--- 3787,3794 ----
to nil.
Optional second argument NOCONFIRM means don't ask for confirmation at
! all. \(The variable `revert-without-query' offers another way to
! revert buffers without querying for confirmation.)
Optional third argument PRESERVE-MODES non-nil means don't alter
the files modes. Normally we reinitialize them using `normal-mode'.
***************
*** 3823,3835 ****
(error "Buffer does not seem to be associated with any file"))
((or noconfirm
(and (not (buffer-modified-p))
! (let ((tail revert-without-query)
! (found nil))
! (while tail
! (if (string-match (car tail) file-name)
! (setq found t))
! (setq tail (cdr tail)))
! found))
(yes-or-no-p (format "Revert buffer from file %s? "
file-name)))
(run-hooks 'before-revert-hook)
--- 3823,3832 ----
(error "Buffer does not seem to be associated with any file"))
((or noconfirm
(and (not (buffer-modified-p))
! (catch 'found
! (dolist (regexp revert-without-query)
! (when (string-match regexp file-name)
! (throw 'found t)))))
(yes-or-no-p (format "Revert buffer from file %s? "
file-name)))
(run-hooks 'before-revert-hook)
***************
*** 3838,3887 ****
(and (not auto-save-p)
(not (verify-visited-file-modtime (current-buffer)))
(setq buffer-backed-up nil))
- ;; Get rid of all undo records for this buffer.
- (or (eq buffer-undo-list t)
- (setq buffer-undo-list nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
(let ((global-hook (default-value 'after-revert-hook))
! (local-hook-p (local-variable-p 'after-revert-hook))
! (local-hook (and (local-variable-p 'after-revert-hook)
! after-revert-hook)))
! (let (buffer-read-only
! ;; Don't make undo records for the reversion.
! (buffer-undo-list t))
! (if revert-buffer-insert-file-contents-function
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)
! (if (not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! ;; Bind buffer-file-name to nil
! ;; so that we don't try to lock the file.
! (let ((buffer-file-name nil))
! (or auto-save-p
! (unlock-buffer)))
! (widen)
! (let ((coding-system-for-read
! ;; Auto-saved file shoule be read by Emacs'
! ;; internal coding.
! (if auto-save-p 'auto-save-coding
! (or coding-system-for-read
! buffer-file-coding-system-explicit))))
! ;; This force after-insert-file-set-coding
! ;; (called from insert-file-contents) to set
! ;; buffer-file-coding-system to a proper value.
! (kill-local-variable 'buffer-file-coding-system)
!
! ;; Note that this preserves point in an intelligent way.
! (if preserve-modes
! (let ((buffer-file-format buffer-file-format))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
--- 3835,3885 ----
(and (not auto-save-p)
(not (verify-visited-file-modtime (current-buffer)))
(setq buffer-backed-up nil))
;; Effectively copy the after-revert-hook status,
;; since after-find-file will clobber it.
(let ((global-hook (default-value 'after-revert-hook))
! (local-hook (when (local-variable-p 'after-revert-hook)
! after-revert-hook))
! (inhibit-read-only t))
! (cond
! (revert-buffer-insert-file-contents-function
! (unless (eq buffer-undo-list t)
! ;; Get rid of all undo records for this buffer.
! (setq buffer-undo-list nil))
! ;; Don't make undo records for the reversion.
! (let ((buffer-undo-list t))
! (funcall revert-buffer-insert-file-contents-function
! file-name auto-save-p)))
! ((not (file-exists-p file-name))
! (error (if buffer-file-number
! "File %s no longer exists!"
! "Cannot revert nonexistent file %s")
! file-name))
! (t
! ;; Bind buffer-file-name to nil
! ;; so that we don't try to lock the file.
! (let ((buffer-file-name nil))
! (or auto-save-p
! (unlock-buffer)))
! (widen)
! (let ((coding-system-for-read
! ;; Auto-saved file should be read by Emacs'
! ;; internal coding.
! (if auto-save-p 'auto-save-coding
! (or coding-system-for-read
! buffer-file-coding-system-explicit))))
! ;; This force after-insert-file-set-coding
! ;; (called from insert-file-contents) to set
! ;; buffer-file-coding-system to a proper value.
! (kill-local-variable 'buffer-file-coding-system)
!
! ;; Note that this preserves point in an intelligent way.
! (if preserve-modes
! (let ((buffer-file-format buffer-file-format))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t))
! (insert-file-contents file-name (not auto-save-p)
! nil nil t)))))
;; Recompute the truename in case changes in symlinks
;; have changed the truename.
(setq buffer-file-truename
***************
*** 3889,3895 ****
(after-find-file nil nil t t preserve-modes)
;; Run after-revert-hook as it was before we reverted.
(setq-default revert-buffer-internal-hook global-hook)
! (if local-hook-p
(set (make-local-variable 'revert-buffer-internal-hook)
local-hook)
(kill-local-variable 'revert-buffer-internal-hook))
--- 3887,3893 ----
(after-find-file nil nil t t preserve-modes)
;; Run after-revert-hook as it was before we reverted.
(setq-default revert-buffer-internal-hook global-hook)
! (if local-hook
(set (make-local-variable 'revert-buffer-internal-hook)
local-hook)
(kill-local-variable 'revert-buffer-internal-hook))
***************
*** 3935,3941 ****
(insert-directory-safely file-name switches))))
(yes-or-no-p (format "Recover auto save file %s? " file-name)))
(switch-to-buffer (find-file-noselect file t))
! (let ((buffer-read-only nil)
;; Keep the current buffer-file-coding-system.
(coding-system buffer-file-coding-system)
;; Auto-saved file shoule be read with special coding.
--- 3933,3939 ----
(insert-directory-safely file-name switches))))
(yes-or-no-p (format "Recover auto save file %s? " file-name)))
(switch-to-buffer (find-file-noselect file t))
! (let ((inhibit-read-only t)
;; Keep the current buffer-file-coding-system.
(coding-system buffer-file-coding-system)
;; Auto-saved file shoule be read with special coding.
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-02-10 8:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-06 7:00 reverting buffer from non-existent file Martin Rudalics
2006-02-07 6:06 ` Richard M. Stallman
2006-02-07 9:44 ` martin rudalics
2006-02-07 15:31 ` Stefan Monnier
2006-02-07 19:27 ` martin rudalics
2006-02-10 8:45 ` martin rudalics
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.