Mercurial > hg > xemacs-beta
comparison src/buffer.c @ 288:e11d67e05968 r21-0b42
Import from CVS: tag r21-0b42
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:35:54 +0200 |
parents | 558f606b08ae |
children | c9fe270a4101 |
comparison
equal
deleted
inserted
replaced
287:13a0bd77a29d | 288:e11d67e05968 |
---|---|
120 | 120 |
121 If a slot is -3, then there is no DEFVAR_BUFFER_LOCAL for it but | 121 If a slot is -3, then there is no DEFVAR_BUFFER_LOCAL for it but |
122 there is a default which is used to initialize newly-creation | 122 there is a default which is used to initialize newly-creation |
123 buffers and as a reset-value when local-vars are killed. */ | 123 buffers and as a reset-value when local-vars are killed. */ |
124 struct buffer buffer_local_flags; | 124 struct buffer buffer_local_flags; |
125 | |
126 /* This is the initial (startup) directory, as used for the *scratch* buffer. | |
127 We're making this a global to make others aware of the startup directory. | |
128 */ | |
129 char initial_directory[MAXPATHLEN+1]; | |
125 | 130 |
126 /* This structure holds the names of symbols whose values may be | 131 /* This structure holds the names of symbols whose values may be |
127 buffer-local. It is indexed and accessed in the same way as the above. */ | 132 buffer-local. It is indexed and accessed in the same way as the above. */ |
128 static Lisp_Object Vbuffer_local_symbols; | 133 static Lisp_Object Vbuffer_local_symbols; |
129 | 134 |
2742 Fbuffer_disable_undo (scratch); | 2747 Fbuffer_disable_undo (scratch); |
2743 } | 2748 } |
2744 } | 2749 } |
2745 | 2750 |
2746 void | 2751 void |
2747 init_buffer (void) | 2752 init_initial_directory (void) |
2748 { | 2753 { |
2749 /* This function can GC */ | 2754 /* This function can GC */ |
2750 char buf[MAXPATHLEN+1]; | 2755 |
2751 char *pwd; | 2756 char *pwd; |
2752 struct stat dotstat, pwdstat; | 2757 struct stat dotstat, pwdstat; |
2753 int rc; | 2758 int rc; |
2754 | 2759 |
2755 buf[0] = 0; | 2760 initial_directory[0] = 0; |
2756 | |
2757 Fset_buffer (Fget_buffer_create (QSscratch)); | |
2758 | 2761 |
2759 /* If PWD is accurate, use it instead of calling getcwd. This is faster | 2762 /* If PWD is accurate, use it instead of calling getcwd. This is faster |
2760 when PWD is right, and may avoid a fatal error. */ | 2763 when PWD is right, and may avoid a fatal error. */ |
2761 if ((pwd = getenv ("PWD")) != 0 && IS_DIRECTORY_SEP (*pwd) | 2764 if ((pwd = getenv ("PWD")) != 0 && IS_DIRECTORY_SEP (*pwd) |
2762 && stat (pwd, &pwdstat) == 0 | 2765 && stat (pwd, &pwdstat) == 0 |
2763 && stat (".", &dotstat) == 0 | 2766 && stat (".", &dotstat) == 0 |
2764 && dotstat.st_ino == pwdstat.st_ino | 2767 && dotstat.st_ino == pwdstat.st_ino |
2765 && dotstat.st_dev == pwdstat.st_dev | 2768 && dotstat.st_dev == pwdstat.st_dev |
2766 && (int) strlen (pwd) < MAXPATHLEN) | 2769 && (int) strlen (pwd) < MAXPATHLEN) |
2767 strcpy (buf, pwd); | 2770 strcpy (initial_directory, pwd); |
2768 else if (getcwd (buf, MAXPATHLEN) == NULL) | 2771 else if (getcwd (initial_directory, MAXPATHLEN) == NULL) |
2769 fatal ("`getcwd' failed: %s\n", strerror (errno)); | 2772 fatal ("`getcwd' failed: %s\n", strerror (errno)); |
2770 | 2773 |
2771 /* Maybe this should really use some standard subroutine | 2774 /* Maybe this should really use some standard subroutine |
2772 whose definition is filename syntax dependent. */ | 2775 whose definition is filename syntax dependent. */ |
2773 rc = strlen (buf); | 2776 rc = strlen (initial_directory); |
2774 if (!(IS_DIRECTORY_SEP (buf[rc - 1]))) | 2777 if (!(IS_DIRECTORY_SEP (initial_directory[rc - 1]))) |
2775 { | 2778 { |
2776 buf[rc] = DIRECTORY_SEP; | 2779 initial_directory[rc] = DIRECTORY_SEP; |
2777 buf[rc + 1] = '\0'; | 2780 initial_directory[rc + 1] = '\0'; |
2778 } | 2781 } |
2779 /* XEmacs change: store buffer's default directory | 2782 /* XEmacs change: store buffer's default directory |
2780 using prefered (i.e. as defined at compile-time) | 2783 using prefered (i.e. as defined at compile-time) |
2781 directory separator. --marcpa */ | 2784 directory separator. --marcpa */ |
2782 #ifdef DOS_NT | 2785 #ifdef DOS_NT |
2783 #define CORRECT_DIR_SEPS(s) \ | 2786 #define CORRECT_DIR_SEPS(s) \ |
2784 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ | 2787 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ |
2785 else unixtodos_filename (s); \ | 2788 else unixtodos_filename (s); \ |
2786 } while (0) | 2789 } while (0) |
2787 | 2790 |
2788 CORRECT_DIR_SEPS(buf); | 2791 CORRECT_DIR_SEPS(initial_directory); |
2789 #endif | 2792 #endif |
2790 current_buffer->directory = build_string (buf); | 2793 } |
2794 | |
2795 void | |
2796 init_buffer (void) | |
2797 { | |
2798 /* This function can GC */ | |
2799 | |
2800 Fset_buffer (Fget_buffer_create (QSscratch)); | |
2801 | |
2802 current_buffer->directory = build_string (initial_directory); | |
2791 | 2803 |
2792 #if 0 /* FSFmacs */ | 2804 #if 0 /* FSFmacs */ |
2793 /* #### is this correct? */ | 2805 /* #### is this correct? */ |
2794 temp = get_minibuffer (0); | 2806 temp = get_minibuffer (0); |
2795 XBUFFER (temp)->directory = current_buffer->directory; | 2807 XBUFFER (temp)->directory = current_buffer->directory; |