diff options
| author | Richard M. Stallman | 2002-09-11 02:03:24 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-09-11 02:03:24 +0000 |
| commit | 5794dd61a086e3e7b008bcac26db1181ec66cb1b (patch) | |
| tree | 4069494ddd882a75027aaa856d81a8cf80b52227 /src | |
| parent | 37d66095580c7ead78a88b6d1ac46edfdb94d5c4 (diff) | |
| download | emacs-5794dd61a086e3e7b008bcac26db1181ec66cb1b.tar.gz emacs-5794dd61a086e3e7b008bcac26db1181ec66cb1b.zip | |
(Fdo_auto_save): Catch error making directory.
Only call push_message if we need to.
At the same time, make an unwind-protect to pop it.
Rename local message_p to old_message_p.
(do_auto_save_make_dir, do_auto_save_eh): New functions.
(do_auto_save_unwind): Don't call pop_message.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/fileio.c b/src/fileio.c index f515442be3c..e48776b18a4 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -5566,7 +5566,6 @@ do_auto_save_unwind (stream) /* used as unwind-protect function */ | |||
| 5566 | if (!NILP (stream)) | 5566 | if (!NILP (stream)) |
| 5567 | fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16 | 5567 | fclose ((FILE *) (XFASTINT (XCAR (stream)) << 16 |
| 5568 | | XFASTINT (XCDR (stream)))); | 5568 | | XFASTINT (XCDR (stream)))); |
| 5569 | pop_message (); | ||
| 5570 | return Qnil; | 5569 | return Qnil; |
| 5571 | } | 5570 | } |
| 5572 | 5571 | ||
| @@ -5578,6 +5577,20 @@ do_auto_save_unwind_1 (value) /* used as unwind-protect function */ | |||
| 5578 | return Qnil; | 5577 | return Qnil; |
| 5579 | } | 5578 | } |
| 5580 | 5579 | ||
| 5580 | static Lisp_Object | ||
| 5581 | do_auto_save_make_dir (dir) | ||
| 5582 | Lisp_Object dir; | ||
| 5583 | { | ||
| 5584 | return call2 (Qmake_directory, dir, Qt); | ||
| 5585 | } | ||
| 5586 | |||
| 5587 | static Lisp_Object | ||
| 5588 | do_auto_save_eh (ignore) | ||
| 5589 | Lisp_Object ignore; | ||
| 5590 | { | ||
| 5591 | return Qnil; | ||
| 5592 | } | ||
| 5593 | |||
| 5581 | DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", | 5594 | DEFUN ("do-auto-save", Fdo_auto_save, Sdo_auto_save, 0, 2, "", |
| 5582 | doc: /* Auto-save all buffers that need it. | 5595 | doc: /* Auto-save all buffers that need it. |
| 5583 | This is all buffers that have auto-saving enabled | 5596 | This is all buffers that have auto-saving enabled |
| @@ -5601,7 +5614,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5601 | Lisp_Object lispstream; | 5614 | Lisp_Object lispstream; |
| 5602 | int count = SPECPDL_INDEX (); | 5615 | int count = SPECPDL_INDEX (); |
| 5603 | int orig_minibuffer_auto_raise = minibuffer_auto_raise; | 5616 | int orig_minibuffer_auto_raise = minibuffer_auto_raise; |
| 5604 | int message_p = 0; | 5617 | int old_message_p = 0; |
| 5605 | 5618 | ||
| 5606 | if (max_specpdl_size < specpdl_size + 40) | 5619 | if (max_specpdl_size < specpdl_size + 40) |
| 5607 | max_specpdl_size = specpdl_size + 40; | 5620 | max_specpdl_size = specpdl_size + 40; |
| @@ -5609,8 +5622,11 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5609 | if (minibuf_level) | 5622 | if (minibuf_level) |
| 5610 | no_message = Qt; | 5623 | no_message = Qt; |
| 5611 | 5624 | ||
| 5612 | if (NILP (no_message)); | 5625 | if (NILP (no_message)) |
| 5613 | message_p = push_message (); | 5626 | { |
| 5627 | old_message_p = push_message (); | ||
| 5628 | record_unwind_protect (pop_message_unwind, Qnil); | ||
| 5629 | } | ||
| 5614 | 5630 | ||
| 5615 | /* Ordinarily don't quit within this function, | 5631 | /* Ordinarily don't quit within this function, |
| 5616 | but don't make it impossible to quit (in case we get hung in I/O). */ | 5632 | but don't make it impossible to quit (in case we get hung in I/O). */ |
| @@ -5637,7 +5653,9 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5637 | Lisp_Object dir; | 5653 | Lisp_Object dir; |
| 5638 | dir = Ffile_name_directory (listfile); | 5654 | dir = Ffile_name_directory (listfile); |
| 5639 | if (NILP (Ffile_directory_p (dir))) | 5655 | if (NILP (Ffile_directory_p (dir))) |
| 5640 | call2 (Qmake_directory, dir, Qt); | 5656 | internal_condition_case_1 (do_auto_save_make_dir, |
| 5657 | dir, Fcons (Fcons (Qfile_error, Qnil), Qnil), | ||
| 5658 | do_auto_save_eh); | ||
| 5641 | } | 5659 | } |
| 5642 | 5660 | ||
| 5643 | stream = fopen (SDATA (listfile), "w"); | 5661 | stream = fopen (SDATA (listfile), "w"); |
| @@ -5765,17 +5783,22 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) | |||
| 5765 | 5783 | ||
| 5766 | if (auto_saved && NILP (no_message)) | 5784 | if (auto_saved && NILP (no_message)) |
| 5767 | { | 5785 | { |
| 5768 | if (message_p) | 5786 | if (old_message_p) |
| 5769 | { | 5787 | { |
| 5788 | /* If we are going to restore an old message, | ||
| 5789 | give time to read ours. */ | ||
| 5770 | sit_for (1, 0, 0, 0, 0); | 5790 | sit_for (1, 0, 0, 0, 0); |
| 5771 | restore_message (); | 5791 | restore_message (); |
| 5772 | } | 5792 | } |
| 5773 | else | 5793 | else |
| 5794 | /* If we displayed a message and then restored a state | ||
| 5795 | with no message, leave a "done" message on the screen. */ | ||
| 5774 | message1 ("Auto-saving...done"); | 5796 | message1 ("Auto-saving...done"); |
| 5775 | } | 5797 | } |
| 5776 | 5798 | ||
| 5777 | Vquit_flag = oquit; | 5799 | Vquit_flag = oquit; |
| 5778 | 5800 | ||
| 5801 | /* This restores the message-stack status. */ | ||
| 5779 | unbind_to (count, Qnil); | 5802 | unbind_to (count, Qnil); |
| 5780 | return Qnil; | 5803 | return Qnil; |
| 5781 | } | 5804 | } |