From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Saving info from inside of error handling
Date: Sat, 29 Mar 2008 09:09:58 -0600 [thread overview]
Message-ID: <fslm45$qcp$1@ger.gmane.org> (raw)
In-Reply-To: <AsKdnauyWLJlg3DanZ2dnUVZ_q6mnZ2d@sysmatrix.net>
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
next prev parent reply other threads:[~2008-03-29 15:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 16:38 Saving info from inside of error handling B. T. Raven
2008-03-29 15:09 ` Kevin Rodgers [this message]
[not found] ` <mailman.9576.1206803413.18990.help-gnu-emacs@gnu.org>
2008-03-30 13:03 ` B. T. Raven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='fslm45$qcp$1@ger.gmane.org' \
--to=kevin.d.rodgers@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).