comparison src/buffer.c @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 501cfd01ee6d
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
82 #include "lstream.h" 82 #include "lstream.h"
83 #include "process.h" /* for kill_buffer_processes */ 83 #include "process.h" /* for kill_buffer_processes */
84 #ifdef REGION_CACHE_NEEDS_WORK 84 #ifdef REGION_CACHE_NEEDS_WORK
85 #include "region-cache.h" 85 #include "region-cache.h"
86 #endif 86 #endif
87 #include "select.h" /* for select_notify_buffer_kill */
87 #include "specifier.h" 88 #include "specifier.h"
88 #include "syntax.h" 89 #include "syntax.h"
89 #include "sysdep.h" /* for getwd */ 90 #include "sysdep.h" /* for getwd */
90 #include "window.h" 91 #include "window.h"
91 92
1218 } 1219 }
1219 } 1220 }
1220 1221
1221 /* Then run the hooks. */ 1222 /* Then run the hooks. */
1222 run_hook (Qkill_buffer_hook); 1223 run_hook (Qkill_buffer_hook);
1223 #ifdef HAVE_X_WINDOWS 1224
1224 /* If an X selection was in this buffer, disown it. 1225 /* Inform the selection code that a buffer just got killed.
1225 We could have done this by simply adding this function to the 1226 We do this in C because (a) it's faster, and (b) it needs
1226 kill-buffer-hook, but the user might mess that up. 1227 to access data internal to select.c that can't be seen from
1227 */ 1228 Lisp (so the Lisp code would just call into C anyway. */
1228 if (EQ (Vwindow_system, Qx)) 1229 select_notify_buffer_kill (buf);
1229 call0 (intern ("xselect-kill-buffer-hook")); 1230
1230 /* #### generalize me! */
1231 #endif /* HAVE_X_WINDOWS */
1232 unbind_to (speccount, Qnil); 1231 unbind_to (speccount, Qnil);
1233 UNGCPRO; 1232 UNGCPRO;
1234 b = XBUFFER (buf); /* Hypothetical relocating GC. */ 1233 b = XBUFFER (buf); /* Hypothetical relocating GC. */
1235 } 1234 }
1236 1235
1478 INVALIDATE_PIXEL_TO_GLYPH_CACHE; 1477 INVALIDATE_PIXEL_TO_GLYPH_CACHE;
1479 1478
1480 old_buf = current_buffer; 1479 old_buf = current_buffer;
1481 current_buffer = b; 1480 current_buffer = b;
1482 invalidate_current_column (); /* invalidate indentation cache */ 1481 invalidate_current_column (); /* invalidate indentation cache */
1483
1484 #ifdef HAVE_FEP
1485 if (!noninteractive && initialized)
1486 {
1487 extern Lisp_Object Ffep_force_on (), Ffep_force_off (), Ffep_get_mode ();
1488
1489 old_buf->fep_mode = Ffep_get_mode ();
1490
1491 if (!NILP (current_buffer->fep_mode))
1492 Ffep_force_on ();
1493 else
1494 Ffep_force_off ();
1495 }
1496 #endif /* HAVE_FEP */
1497 1482
1498 if (old_buf) 1483 if (old_buf)
1499 { 1484 {
1500 /* Put the undo list back in the base buffer, so that it appears 1485 /* Put the undo list back in the base buffer, so that it appears
1501 that an indirect buffer shares the undo list of its base. */ 1486 that an indirect buffer shares the undo list of its base. */
3112 /* Want no undo records for *scratch* until after Emacs is dumped */ 3097 /* Want no undo records for *scratch* until after Emacs is dumped */
3113 Fbuffer_disable_undo (scratch); 3098 Fbuffer_disable_undo (scratch);
3114 } 3099 }
3115 } 3100 }
3116 3101
3102 #ifndef WIN32_NATIVE
3117 /* Is PWD another name for `.' ? */ 3103 /* Is PWD another name for `.' ? */
3118 static int 3104 static int
3119 directory_is_current_directory (Extbyte *pwd) 3105 directory_is_current_directory (Extbyte *pwd)
3120 { 3106 {
3121 Bufbyte *pwd_internal; 3107 Bufbyte *pwd_internal;
3131 && stat (".", &dotstat) == 0 3117 && stat (".", &dotstat) == 0
3132 && dotstat.st_ino == pwdstat.st_ino 3118 && dotstat.st_ino == pwdstat.st_ino
3133 && dotstat.st_dev == pwdstat.st_dev 3119 && dotstat.st_dev == pwdstat.st_dev
3134 && pwd_internal_len < MAXPATHLEN); 3120 && pwd_internal_len < MAXPATHLEN);
3135 } 3121 }
3122 #endif
3136 3123
3137 void 3124 void
3138 init_initial_directory (void) 3125 init_initial_directory (void)
3139 { 3126 {
3140 /* This function can GC */ 3127 /* This function can GC */
3141 3128
3129 #ifndef WIN32_NATIVE
3142 Extbyte *pwd; 3130 Extbyte *pwd;
3131 #endif
3143 3132
3144 initial_directory[0] = 0; 3133 initial_directory[0] = 0;
3145 3134
3146 /* If PWD is accurate, use it instead of calling getcwd. This is faster 3135 /* If PWD is accurate, use it instead of calling getcwd. This is faster
3147 when PWD is right, and may avoid a fatal error. */ 3136 when PWD is right, and may avoid a fatal error. */
3137 #ifndef WIN32_NATIVE
3148 if ((pwd = (Extbyte *) getenv ("PWD")) != NULL 3138 if ((pwd = (Extbyte *) getenv ("PWD")) != NULL
3149 && directory_is_current_directory (pwd)) 3139 && directory_is_current_directory (pwd))
3150 strcpy (initial_directory, (char *) pwd); 3140 strcpy (initial_directory, (char *) pwd);
3151 else if (getcwd (initial_directory, MAXPATHLEN) == NULL) 3141 else
3152 fatal ("`getcwd' failed: %s\n", strerror (errno)); 3142 #endif
3143 if (getcwd (initial_directory, MAXPATHLEN) == NULL)
3144 fatal ("`getcwd' failed: %s\n", strerror (errno));
3153 3145
3154 /* Make sure pwd is DIRECTORY_SEP-terminated. 3146 /* Make sure pwd is DIRECTORY_SEP-terminated.
3155 Maybe this should really use some standard subroutine 3147 Maybe this should really use some standard subroutine
3156 whose definition is filename syntax dependent. */ 3148 whose definition is filename syntax dependent. */
3157 { 3149 {
3162 initial_directory[len] = DIRECTORY_SEP; 3154 initial_directory[len] = DIRECTORY_SEP;
3163 initial_directory[len + 1] = '\0'; 3155 initial_directory[len + 1] = '\0';
3164 } 3156 }
3165 } 3157 }
3166 3158
3167 /* XEmacs change: store buffer's default directory 3159 #ifdef CORRECT_DIR_SEPS
3168 using preferred (i.e. as defined at compile-time) 3160 CORRECT_DIR_SEPS (initial_directory);
3169 directory separator. --marcpa */
3170 #ifdef DOS_NT
3171 #define CORRECT_DIR_SEPS(s) \
3172 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \
3173 else unixtodos_filename (s); \
3174 } while (0)
3175
3176 CORRECT_DIR_SEPS(initial_directory);
3177 #endif 3161 #endif
3178 } 3162 }
3179 3163
3180 void 3164 void
3181 init_buffer (void) 3165 init_buffer (void)