diff options
| author | Richard M. Stallman | 1998-03-02 19:08:05 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-02 19:08:05 +0000 |
| commit | de1d0127029260011436d5bfd5114503a69bf612 (patch) | |
| tree | 15fcd13e34e91b8c0d5a5cc37cc9a1bd5bf4be8d /src | |
| parent | 7d88962ce8e270f3ce3cda530ce862b2ee95a891 (diff) | |
| download | emacs-de1d0127029260011436d5bfd5114503a69bf612.tar.gz emacs-de1d0127029260011436d5bfd5114503a69bf612.zip | |
(auto_save_1): Pass new arg to Fwrite_region.
(Fwrite_region): New arg CONFIRM. If non-nil, confirm overwriting.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/fileio.c b/src/fileio.c index c2dd2039b42..6c6e073ca47 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2042,8 +2042,10 @@ expand_and_dir_to_file (filename, defdir) | |||
| 2042 | and bypass the error if the user says to go ahead. | 2042 | and bypass the error if the user says to go ahead. |
| 2043 | QUERYSTRING is a name for the action that is being considered | 2043 | QUERYSTRING is a name for the action that is being considered |
| 2044 | to alter the file. | 2044 | to alter the file. |
| 2045 | |||
| 2045 | *STATPTR is used to store the stat information if the file exists. | 2046 | *STATPTR is used to store the stat information if the file exists. |
| 2046 | If the file does not exist, STATPTR->st_mode is set to 0. */ | 2047 | If the file does not exist, STATPTR->st_mode is set to 0. |
| 2048 | If STATPTR is null, we don't store into it. */ | ||
| 2047 | 2049 | ||
| 2048 | void | 2050 | void |
| 2049 | barf_or_query_if_file_exists (absname, querystring, interactive, statptr) | 2051 | barf_or_query_if_file_exists (absname, querystring, interactive, statptr) |
| @@ -3916,8 +3918,8 @@ build_annotations_unwind (buf) | |||
| 3916 | return Qnil; | 3918 | return Qnil; |
| 3917 | } | 3919 | } |
| 3918 | 3920 | ||
| 3919 | DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 6, | 3921 | DEFUN ("write-region", Fwrite_region, Swrite_region, 3, 7, |
| 3920 | "r\nFWrite region to file: ", | 3922 | "r\nFWrite region to file: \ni\ni\ni\np", |
| 3921 | "Write current region into specified file.\n\ | 3923 | "Write current region into specified file.\n\ |
| 3922 | When called from a program, takes three arguments:\n\ | 3924 | When called from a program, takes three arguments:\n\ |
| 3923 | START, END and FILENAME. START and END are buffer positions.\n\ | 3925 | START, END and FILENAME. START and END are buffer positions.\n\ |
| @@ -3933,10 +3935,12 @@ If VISIT is neither t nor nil nor a string,\n\ | |||
| 3933 | that means do not print the \"Wrote file\" message.\n\ | 3935 | that means do not print the \"Wrote file\" message.\n\ |
| 3934 | The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\ | 3936 | The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\ |
| 3935 | use for locking and unlocking, overriding FILENAME and VISIT.\n\ | 3937 | use for locking and unlocking, overriding FILENAME and VISIT.\n\ |
| 3938 | The optional seventh arg CONFIRM, if non-nil, says ask for confirmation\n\ | ||
| 3939 | before overwriting an existing file.\n\ | ||
| 3936 | Kludgy feature: if START is a string, then that string is written\n\ | 3940 | Kludgy feature: if START is a string, then that string is written\n\ |
| 3937 | to the file, instead of any buffer contents, and END is ignored.") | 3941 | to the file, instead of any buffer contents, and END is ignored.") |
| 3938 | (start, end, filename, append, visit, lockname) | 3942 | (start, end, filename, append, visit, lockname, confirm) |
| 3939 | Lisp_Object start, end, filename, append, visit, lockname; | 3943 | Lisp_Object start, end, filename, append, visit, lockname, confirm; |
| 3940 | { | 3944 | { |
| 3941 | register int desc; | 3945 | register int desc; |
| 3942 | int failure; | 3946 | int failure; |
| @@ -4029,6 +4033,10 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 4029 | Vlast_coding_system_used = coding.symbol; | 4033 | Vlast_coding_system_used = coding.symbol; |
| 4030 | 4034 | ||
| 4031 | filename = Fexpand_file_name (filename, Qnil); | 4035 | filename = Fexpand_file_name (filename, Qnil); |
| 4036 | |||
| 4037 | if (! NILP (confirm)) | ||
| 4038 | barf_or_query_if_file_exists (filename, "overwrite", 1, 0); | ||
| 4039 | |||
| 4032 | if (STRINGP (visit)) | 4040 | if (STRINGP (visit)) |
| 4033 | visit_file = Fexpand_file_name (visit, Qnil); | 4041 | visit_file = Fexpand_file_name (visit, Qnil); |
| 4034 | else | 4042 | else |
| @@ -4671,7 +4679,7 @@ auto_save_1 () | |||
| 4671 | return | 4679 | return |
| 4672 | Fwrite_region (Qnil, Qnil, | 4680 | Fwrite_region (Qnil, Qnil, |
| 4673 | current_buffer->auto_save_file_name, | 4681 | current_buffer->auto_save_file_name, |
| 4674 | Qnil, Qlambda, Qnil); | 4682 | Qnil, Qlambda, Qnil, Qnil); |
| 4675 | } | 4683 | } |
| 4676 | 4684 | ||
| 4677 | static Lisp_Object | 4685 | static Lisp_Object |