diff options
| author | Richard M. Stallman | 1994-05-10 23:26:39 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-05-10 23:26:39 +0000 |
| commit | e54d3b5db2a1fca071769083ae89783edddd8ae5 (patch) | |
| tree | 27290441c3e8d20dc3ee3df03b4195ef15d03a7c /src | |
| parent | 097c282404b591c94e6de554077dd7bbf171fd9c (diff) | |
| download | emacs-e54d3b5db2a1fca071769083ae89783edddd8ae5.tar.gz emacs-e54d3b5db2a1fca071769083ae89783edddd8ae5.zip | |
(Finsert_file_contents) [MSDOS]: Ignore the replace feature.
(Fdo_auto_save): Write a list of all auto save file names.
(Vauto_save_list_file_name): Specify file name to put them in.
(syms_of_fileio): Set up Lisp var.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 36e8ba0f41b..0df30ef2c43 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -121,6 +121,9 @@ Lisp_Object Vafter_insert_file_functions; | |||
| 121 | /* Functions to be called to create text property annotations for file. */ | 121 | /* Functions to be called to create text property annotations for file. */ |
| 122 | Lisp_Object Vwrite_region_annotate_functions; | 122 | Lisp_Object Vwrite_region_annotate_functions; |
| 123 | 123 | ||
| 124 | /* File name in which we write a list of all our auto save files. */ | ||
| 125 | Lisp_Object Vauto_save_list_file_name; | ||
| 126 | |||
| 124 | /* Nonzero means, when reading a filename in the minibuffer, | 127 | /* Nonzero means, when reading a filename in the minibuffer, |
| 125 | start out by inserting the default directory into the minibuffer. */ | 128 | start out by inserting the default directory into the minibuffer. */ |
| 126 | int insert_default_directory; | 129 | int insert_default_directory; |
| @@ -2645,6 +2648,17 @@ and (2) it puts less data in the undo list.") | |||
| 2645 | with the file contents. Avoid replacing text at the | 2648 | with the file contents. Avoid replacing text at the |
| 2646 | beginning or end of the buffer that matches the file contents; | 2649 | beginning or end of the buffer that matches the file contents; |
| 2647 | that preserves markers pointing to the unchanged parts. */ | 2650 | that preserves markers pointing to the unchanged parts. */ |
| 2651 | #ifdef MSDOS | ||
| 2652 | /* On MSDOS, replace mode doesn't really work, except for binary files, | ||
| 2653 | and it's not worth supporting just for them. */ | ||
| 2654 | if (!NILP (replace)) | ||
| 2655 | { | ||
| 2656 | replace = Qnil; | ||
| 2657 | XFASTINT (beg) = 0; | ||
| 2658 | XFASTINT (end) = st.st_size; | ||
| 2659 | del_range_1 (BEGV, ZV, 0); | ||
| 2660 | } | ||
| 2661 | #else /* MSDOS */ | ||
| 2648 | if (!NILP (replace)) | 2662 | if (!NILP (replace)) |
| 2649 | { | 2663 | { |
| 2650 | char buffer[1 << 14]; | 2664 | char buffer[1 << 14]; |
| @@ -2737,6 +2751,7 @@ and (2) it puts less data in the undo list.") | |||
| 2737 | /* Insert from the file at the proper position. */ | 2751 | /* Insert from the file at the proper position. */ |
| 2738 | SET_PT (same_at_start); | 2752 | SET_PT (same_at_start); |
| 2739 | } | 2753 | } |
| 2754 | #endif /* MSDOS */ | ||
| 2740 | 2755 | ||
| 2741 | total = XINT (end) - XINT (beg); | 2756 | total = XINT (end) - XINT (beg); |
| 2742 | 2757 | ||
| @@ -3457,6 +3472,15 @@ auto_save_1 () | |||
| 3457 | Qnil, Qlambda); | 3472 | Qnil, Qlambda); |
| 3458 | } | 3473 | } |
| 3459 | 3474 | ||
| 3475 | static Lisp_Object | ||
| 3476 | do_auto_save_unwind (stream) /* used as unwind-protect function */ | ||
| 3477 | Lisp_Object stream; | ||
| 3478 | { | ||
| 3479 | close (*(int *)XPNTR (stream)); | ||
| 3480 | xfree (XPNTR (stream)); | ||
| 3481 | return Qnil; | ||
| 3482 | } | ||
| 3483 | |||
| 3460 | DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", | 3484 | DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", |
| 3461 | "Auto-save all buffers that need it.\n\ | 3485 | "Auto-save all buffers that need it.\n\ |
| 3462 | This is all buffers that have auto-saving enabled\n\ | 3486 | This is all buffers that have auto-saving enabled\n\ |
| @@ -3478,6 +3502,10 @@ Non-nil second argument means save only current buffer.") | |||
| 3478 | extern int minibuf_level; | 3502 | extern int minibuf_level; |
| 3479 | int do_handled_files; | 3503 | int do_handled_files; |
| 3480 | Lisp_Object oquit; | 3504 | Lisp_Object oquit; |
| 3505 | int listdesc; | ||
| 3506 | Lisp_Object lispstream; | ||
| 3507 | int count = specpdl_ptr - specpdl; | ||
| 3508 | int *ptr; | ||
| 3481 | 3509 | ||
| 3482 | /* Ordinarily don't quit within this function, | 3510 | /* Ordinarily don't quit within this function, |
| 3483 | but don't make it impossible to quit (in case we get hung in I/O). */ | 3511 | but don't make it impossible to quit (in case we get hung in I/O). */ |
| @@ -3494,6 +3522,28 @@ Non-nil second argument means save only current buffer.") | |||
| 3494 | if (!NILP (Vrun_hooks)) | 3522 | if (!NILP (Vrun_hooks)) |
| 3495 | call1 (Vrun_hooks, intern ("auto-save-hook")); | 3523 | call1 (Vrun_hooks, intern ("auto-save-hook")); |
| 3496 | 3524 | ||
| 3525 | if (STRINGP (Vauto_save_list_file_name)) | ||
| 3526 | { | ||
| 3527 | #ifdef MSDOS | ||
| 3528 | listdesc = open (XSTRING (Vauto_save_list_file_name)->data, | ||
| 3529 | O_WRONLY | O_TRUNC | O_CREAT | O_TEXT, | ||
| 3530 | S_IREAD | S_IWRITE); | ||
| 3531 | #else /* not MSDOS */ | ||
| 3532 | listdesc = creat (XSTRING (Vauto_save_list_file_name)->data, 0666); | ||
| 3533 | #endif /* not MSDOS */ | ||
| 3534 | } | ||
| 3535 | else | ||
| 3536 | listdesc = -1; | ||
| 3537 | |||
| 3538 | /* We may not be able to store STREAM itself as a Lisp_Object pointer | ||
| 3539 | since that is guaranteed to work only for data that has been malloc'd. | ||
| 3540 | So malloc a full-size pointer, and record the address of that pointer. */ | ||
| 3541 | ptr = (int *) xmalloc (sizeof (int)); | ||
| 3542 | *ptr = listdesc; | ||
| 3543 | XSET (lispstream, Lisp_Internal_Stream, (int) ptr); | ||
| 3544 | |||
| 3545 | record_unwind_protect (do_auto_save_unwind, lispstream); | ||
| 3546 | |||
| 3497 | /* First, save all files which don't have handlers. If Emacs is | 3547 | /* First, save all files which don't have handlers. If Emacs is |
| 3498 | crashing, the handlers may tweak what is causing Emacs to crash | 3548 | crashing, the handlers may tweak what is causing Emacs to crash |
| 3499 | in the first place, and it would be a shame if Emacs failed to | 3549 | in the first place, and it would be a shame if Emacs failed to |
| @@ -3505,11 +3555,21 @@ Non-nil second argument means save only current buffer.") | |||
| 3505 | { | 3555 | { |
| 3506 | buf = XCONS (XCONS (tail)->car)->cdr; | 3556 | buf = XCONS (XCONS (tail)->car)->cdr; |
| 3507 | b = XBUFFER (buf); | 3557 | b = XBUFFER (buf); |
| 3558 | |||
| 3559 | /* Record all the buffers that have auto save mode | ||
| 3560 | in the special file that lists them. */ | ||
| 3561 | if (XTYPE (b->auto_save_file_name) == Lisp_String | ||
| 3562 | && listdesc >= 0 && do_handled_files == 0) | ||
| 3563 | { | ||
| 3564 | write (listdesc, XSTRING (b->auto_save_file_name)->data, | ||
| 3565 | XSTRING (b->auto_save_file_name)->size); | ||
| 3566 | write (listdesc, "\n", 1); | ||
| 3567 | } | ||
| 3508 | 3568 | ||
| 3509 | if (!NILP (current_only) | 3569 | if (!NILP (current_only) |
| 3510 | && b != current_buffer) | 3570 | && b != current_buffer) |
| 3511 | continue; | 3571 | continue; |
| 3512 | 3572 | ||
| 3513 | /* Check for auto save enabled | 3573 | /* Check for auto save enabled |
| 3514 | and file changed since last auto save | 3574 | and file changed since last auto save |
| 3515 | and file changed since last real save. */ | 3575 | and file changed since last real save. */ |
| @@ -3581,6 +3641,7 @@ Non-nil second argument means save only current buffer.") | |||
| 3581 | Vquit_flag = oquit; | 3641 | Vquit_flag = oquit; |
| 3582 | 3642 | ||
| 3583 | auto_saving = 0; | 3643 | auto_saving = 0; |
| 3644 | unbind_to (count, Qnil); | ||
| 3584 | return Qnil; | 3645 | return Qnil; |
| 3585 | } | 3646 | } |
| 3586 | 3647 | ||
| @@ -4007,6 +4068,10 @@ This applies only to the operation `inhibit-file-name-operation'."); | |||
| 4007 | "The operation for which `inhibit-file-name-handlers' is applicable."); | 4068 | "The operation for which `inhibit-file-name-handlers' is applicable."); |
| 4008 | Vinhibit_file_name_operation = Qnil; | 4069 | Vinhibit_file_name_operation = Qnil; |
| 4009 | 4070 | ||
| 4071 | DEFVAR_LISP ("auto-save-list-file-name", &Vauto_save_list_file_name, | ||
| 4072 | "File name in which we write a list of all auto save file names."); | ||
| 4073 | Vauto_save_list_file_name = Qnil; | ||
| 4074 | |||
| 4010 | defsubr (&Sfind_file_name_handler); | 4075 | defsubr (&Sfind_file_name_handler); |
| 4011 | defsubr (&Sfile_name_directory); | 4076 | defsubr (&Sfile_name_directory); |
| 4012 | defsubr (&Sfile_name_nondirectory); | 4077 | defsubr (&Sfile_name_nondirectory); |