comparison src/fileio.c @ 1775:f9ac4c0d8b72

* fileio.c (Fdo_auto_save): Add CURRENT_ONLY argument, as described in doc string.
author Jim Blandy <jimb@redhat.com>
date Thu, 14 Jan 1993 15:08:15 +0000
parents 65e858c07a8b
children 30eb06b22ae4
comparison
equal deleted inserted replaced
1774:04cd18603ec5 1775:f9ac4c0d8b72
2865 Auto-saving writes the buffer into a file\n\ 2865 Auto-saving writes the buffer into a file\n\
2866 so that your editing is not lost if the system crashes.\n\ 2866 so that your editing is not lost if the system crashes.\n\
2867 This file is not the file you visited; that changes only when you save.\n\n\ 2867 This file is not the file you visited; that changes only when you save.\n\n\
2868 Non-nil first argument means do not print any message if successful.\n\ 2868 Non-nil first argument means do not print any message if successful.\n\
2869 Non-nil second argument means save only current buffer.") 2869 Non-nil second argument means save only current buffer.")
2870 (nomsg) 2870 (no_message, current_only)
2871 Lisp_Object nomsg; 2871 Lisp_Object no_message, current_only;
2872 { 2872 {
2873 struct buffer *old = current_buffer, *b; 2873 struct buffer *old = current_buffer, *b;
2874 Lisp_Object tail, buf; 2874 Lisp_Object tail, buf;
2875 int auto_saved = 0; 2875 int auto_saved = 0;
2876 char *omessage = echo_area_glyphs; 2876 char *omessage = echo_area_glyphs;
2879 /* No GCPRO needed, because (when it matters) all Lisp_Object variables 2879 /* No GCPRO needed, because (when it matters) all Lisp_Object variables
2880 point to non-strings reached from Vbuffer_alist. */ 2880 point to non-strings reached from Vbuffer_alist. */
2881 2881
2882 auto_saving = 1; 2882 auto_saving = 1;
2883 if (minibuf_level) 2883 if (minibuf_level)
2884 nomsg = Qt; 2884 no_message = Qt;
2885 2885
2886 /* Vrun_hooks is nil before emacs is dumped, and inc-vers.el will 2886 /* Vrun_hooks is nil before emacs is dumped, and inc-vers.el will
2887 eventually call do-auto-save, so don't err here in that case. */ 2887 eventually call do-auto-save, so don't err here in that case. */
2888 if (!NILP (Vrun_hooks)) 2888 if (!NILP (Vrun_hooks))
2889 call1 (Vrun_hooks, intern ("auto-save-hook")); 2889 call1 (Vrun_hooks, intern ("auto-save-hook"));
2891 for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons; 2891 for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons;
2892 tail = XCONS (tail)->cdr) 2892 tail = XCONS (tail)->cdr)
2893 { 2893 {
2894 buf = XCONS (XCONS (tail)->car)->cdr; 2894 buf = XCONS (XCONS (tail)->car)->cdr;
2895 b = XBUFFER (buf); 2895 b = XBUFFER (buf);
2896
2897 if (!NILP (current_only)
2898 && b != current_buffer)
2899 continue;
2900
2896 /* Check for auto save enabled 2901 /* Check for auto save enabled
2897 and file changed since last auto save 2902 and file changed since last auto save
2898 and file changed since last real save. */ 2903 and file changed since last real save. */
2899 if (XTYPE (b->auto_save_file_name) == Lisp_String 2904 if (XTYPE (b->auto_save_file_name) == Lisp_String
2900 && b->save_modified < BUF_MODIFF (b) 2905 && b->save_modified < BUF_MODIFF (b)
2917 XFASTINT (b->save_length) = 0; 2922 XFASTINT (b->save_length) = 0;
2918 Fsleep_for (make_number (1), Qnil); 2923 Fsleep_for (make_number (1), Qnil);
2919 continue; 2924 continue;
2920 } 2925 }
2921 set_buffer_internal (b); 2926 set_buffer_internal (b);
2922 if (!auto_saved && NILP (nomsg)) 2927 if (!auto_saved && NILP (no_message))
2923 message1 ("Auto-saving..."); 2928 message1 ("Auto-saving...");
2924 internal_condition_case (auto_save_1, Qt, auto_save_error); 2929 internal_condition_case (auto_save_1, Qt, auto_save_error);
2925 auto_saved++; 2930 auto_saved++;
2926 b->auto_save_modified = BUF_MODIFF (b); 2931 b->auto_save_modified = BUF_MODIFF (b);
2927 XFASTINT (current_buffer->save_length) = Z - BEG; 2932 XFASTINT (current_buffer->save_length) = Z - BEG;
2930 } 2935 }
2931 2936
2932 /* Prevent another auto save till enough input events come in. */ 2937 /* Prevent another auto save till enough input events come in. */
2933 record_auto_save (); 2938 record_auto_save ();
2934 2939
2935 if (auto_saved && NILP (nomsg)) 2940 if (auto_saved && NILP (no_message))
2936 message1 (omessage ? omessage : "Auto-saving...done"); 2941 message1 (omessage ? omessage : "Auto-saving...done");
2937 2942
2938 auto_saving = 0; 2943 auto_saving = 0;
2939 return Qnil; 2944 return Qnil;
2940 } 2945 }