[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Saving info from inside of error handling
From: |
Kevin Rodgers |
Subject: |
Re: Saving info from inside of error handling |
Date: |
Sat, 29 Mar 2008 09:09:58 -0600 |
User-agent: |
Thunderbird 2.0.0.12 (Macintosh/20080213) |
B. T. Raven wrote:
I have the following inside a loop where filename is changed and I want
to build a string or list of filenames for which the user has answered
that the existing file should be overwritten. Can I test for y-or-n-p
return result (write-file defun in files.el) and have the program report
in which places the files have been replaced with the contents of the
current buffer?
(condition-case nil
(write-file filename t)
(error nil))
I don't think you can reliably test the result of that particular
call to y-or-n-p (there are 2 calls in basic-save-buffer, plus 1 call
to yes-or-no-p). But you can test whether the visited file name has
changed:
(let ((overwritten-files '())
original-file-name)
...
(setq original-file buffer-file-name)
(condition-case nil
(write-file filename t)
(error nil))
(when (not (equal original-file-name buffer-file-name))
(setq overwritten-files
(cons (cons original-file-name buffer-file-name) overwritten-files)))
...
)
--
Kevin Rodgers
Denver, Colorado, USA