aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-02-14 14:37:33 +0000
committerJim Blandy1993-02-14 14:37:33 +0000
commitf14b1c68f4634d4c43d45f5a566d5bf7601b4efc (patch)
tree466116e5e2a37729aa7dd040e873e5f4afb1333c /src
parent72a8c21efbe41c9462e9c004b2b8114dc8773537 (diff)
downloademacs-f14b1c68f4634d4c43d45f5a566d5bf7601b4efc.tar.gz
emacs-f14b1c68f4634d4c43d45f5a566d5bf7601b4efc.zip
* fileio.c (Fdo_auto_save): If NO_MESSAGE is non-nil, don't tell
users that buffers have shrunk a lot. This is called when Emacs is crashing, so we don't want to run any code that isn't absolutely necessary. Also, autosave buffers which don't have specially handled autosave file names first. * fileio.c (Fexpand_file_name): Pass DEFALT through Fexpand_file_name before using it. * fileio.c (Fexpand_file_name): Doc fix.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c125
1 files changed, 79 insertions, 46 deletions
diff --git a/src/fileio.c b/src/fileio.c
index e17dc6d8e46..e4f7af72195 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -597,7 +597,6 @@ See also the function `substitute-in-file-name'.")
597 int tlen; 597 int tlen;
598 unsigned char *target; 598 unsigned char *target;
599 struct passwd *pw; 599 struct passwd *pw;
600 int lose;
601#ifdef VMS 600#ifdef VMS
602 unsigned char * colon = 0; 601 unsigned char * colon = 0;
603 unsigned char * close = 0; 602 unsigned char * close = 0;
@@ -616,6 +615,23 @@ See also the function `substitute-in-file-name'.")
616 if (!NILP (handler)) 615 if (!NILP (handler))
617 return call3 (handler, Qexpand_file_name, name, defalt); 616 return call3 (handler, Qexpand_file_name, name, defalt);
618 617
618 /* Make sure DEFALT is properly expanded.
619 It would be better to do this down below where we actually use
620 defalt. Unfortunately, calling Fexpand_file_name recursively
621 could invoke GC, and the strings might be relocated. This would
622 be annoying because we have pointers into strings lying around
623 that would need adjusting, and people would add new pointers to
624 the code and forget to adjust them, resulting in intermittent bugs.
625 Putting this call here avoids all that crud. */
626 if (! NILP (defalt))
627 {
628 struct gcpro gcpro1;
629
630 GCPRO1 (name);
631 defalt = Fexpand_file_name (defalt, Qnil);
632 UNGCPRO;
633 }
634
619#ifdef VMS 635#ifdef VMS
620 /* Filenames on VMS are always upper case. */ 636 /* Filenames on VMS are always upper case. */
621 name = Fupcase (name); 637 name = Fupcase (name);
@@ -632,8 +648,15 @@ See also the function `substitute-in-file-name'.")
632#endif /* VMS */ 648#endif /* VMS */
633 ) 649 )
634 { 650 {
651 /* If it turns out that the filename we want to return is just a
652 suffix of FILENAME, we don't need to go through and edit
653 things; we just need to construct a new string using data
654 starting at the middle of FILENAME. If we set lose to a
655 non-zero value, that means we've discovered that we can't do
656 that cool trick. */
657 int lose = 0;
658
635 p = nm; 659 p = nm;
636 lose = 0;
637 while (*p) 660 while (*p)
638 { 661 {
639 /* Since we know the path is absolute, we can assume that each 662 /* Since we know the path is absolute, we can assume that each
@@ -2874,7 +2897,8 @@ Non-nil second argument means save only current buffer.")
2874 Lisp_Object tail, buf; 2897 Lisp_Object tail, buf;
2875 int auto_saved = 0; 2898 int auto_saved = 0;
2876 char *omessage = echo_area_glyphs; 2899 char *omessage = echo_area_glyphs;
2877 extern minibuf_level; 2900 extern int minibuf_level;
2901 int do_handled_files;
2878 2902
2879 /* No GCPRO needed, because (when it matters) all Lisp_Object variables 2903 /* No GCPRO needed, because (when it matters) all Lisp_Object variables
2880 point to non-strings reached from Vbuffer_alist. */ 2904 point to non-strings reached from Vbuffer_alist. */
@@ -2888,51 +2912,60 @@ Non-nil second argument means save only current buffer.")
2888 if (!NILP (Vrun_hooks)) 2912 if (!NILP (Vrun_hooks))
2889 call1 (Vrun_hooks, intern ("auto-save-hook")); 2913 call1 (Vrun_hooks, intern ("auto-save-hook"));
2890 2914
2891 for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons; 2915 /* First, save all files which don't have handlers. If Emacs is
2892 tail = XCONS (tail)->cdr) 2916 crashing, the handlers may tweak what is causing Emacs to crash
2893 { 2917 in the first place, and it would be a shame if Emacs failed to
2894 buf = XCONS (XCONS (tail)->car)->cdr; 2918 autosave perfectly ordinary files because it couldn't handle some
2895 b = XBUFFER (buf); 2919 ange-ftp'd file. */
2920 for (do_handled_files = 0; do_handled_files < 2; do_handled_files++)
2921 for (tail = Vbuffer_alist; XGCTYPE (tail) == Lisp_Cons;
2922 tail = XCONS (tail)->cdr)
2923 {
2924 buf = XCONS (XCONS (tail)->car)->cdr;
2925 b = XBUFFER (buf);
2896 2926
2897 if (!NILP (current_only) 2927 if (!NILP (current_only)
2898 && b != current_buffer) 2928 && b != current_buffer)
2899 continue; 2929 continue;
2900 2930
2901 /* Check for auto save enabled 2931 /* Check for auto save enabled
2902 and file changed since last auto save 2932 and file changed since last auto save
2903 and file changed since last real save. */ 2933 and file changed since last real save. */
2904 if (XTYPE (b->auto_save_file_name) == Lisp_String 2934 if (XTYPE (b->auto_save_file_name) == Lisp_String
2905 && b->save_modified < BUF_MODIFF (b) 2935 && b->save_modified < BUF_MODIFF (b)
2906 && b->auto_save_modified < BUF_MODIFF (b)) 2936 && b->auto_save_modified < BUF_MODIFF (b)
2907 { 2937 && (do_handled_files
2908 if ((XFASTINT (b->save_length) * 10 2938 || NILP (Ffind_file_name_handler (b->auto_save_file_name))))
2909 > (BUF_Z (b) - BUF_BEG (b)) * 13) 2939 {
2910 /* A short file is likely to change a large fraction; 2940 if ((XFASTINT (b->save_length) * 10
2911 spare the user annoying messages. */ 2941 > (BUF_Z (b) - BUF_BEG (b)) * 13)
2912 && XFASTINT (b->save_length) > 5000 2942 /* A short file is likely to change a large fraction;
2913 /* These messages are frequent and annoying for `*mail*'. */ 2943 spare the user annoying messages. */
2914 && !EQ (b->filename, Qnil)) 2944 && XFASTINT (b->save_length) > 5000
2915 { 2945 /* These messages are frequent and annoying for `*mail*'. */
2916 /* It has shrunk too much; turn off auto-saving here. */ 2946 && !EQ (b->filename, Qnil)
2917 message ("Buffer %s has shrunk a lot; auto save turned off there", 2947 && NILP (no_message))
2918 XSTRING (b->name)->data); 2948 {
2919 /* User can reenable saving with M-x auto-save. */ 2949 /* It has shrunk too much; turn off auto-saving here. */
2920 b->auto_save_file_name = Qnil; 2950 message ("Buffer %s has shrunk a lot; auto save turned off there",
2921 /* Prevent warning from repeating if user does so. */ 2951 XSTRING (b->name)->data);
2922 XFASTINT (b->save_length) = 0; 2952 /* User can reenable saving with M-x auto-save. */
2923 Fsleep_for (make_number (1), Qnil); 2953 b->auto_save_file_name = Qnil;
2924 continue; 2954 /* Prevent warning from repeating if user does so. */
2925 } 2955 XFASTINT (b->save_length) = 0;
2926 set_buffer_internal (b); 2956 Fsleep_for (make_number (1), Qnil);
2927 if (!auto_saved && NILP (no_message)) 2957 continue;
2928 message1 ("Auto-saving..."); 2958 }
2929 internal_condition_case (auto_save_1, Qt, auto_save_error); 2959 set_buffer_internal (b);
2930 auto_saved++; 2960 if (!auto_saved && NILP (no_message))
2931 b->auto_save_modified = BUF_MODIFF (b); 2961 message1 ("Auto-saving...");
2932 XFASTINT (current_buffer->save_length) = Z - BEG; 2962 internal_condition_case (auto_save_1, Qt, auto_save_error);
2933 set_buffer_internal (old); 2963 auto_saved++;
2934 } 2964 b->auto_save_modified = BUF_MODIFF (b);
2935 } 2965 XFASTINT (current_buffer->save_length) = Z - BEG;
2966 set_buffer_internal (old);
2967 }
2968 }
2936 2969
2937 /* Prevent another auto save till enough input events come in. */ 2970 /* Prevent another auto save till enough input events come in. */
2938 record_auto_save (); 2971 record_auto_save ();