aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorGlenn Morris2015-06-11 20:34:54 -0400
committerGlenn Morris2015-06-11 20:34:54 -0400
commitebbc6a4782c279527c52d6b1d8b379517aeec2d5 (patch)
tree13294b8212776555f38defad43d82c8e0020510f /src/buffer.c
parent32e53667a91ed479743175d5698a89b163c8be94 (diff)
downloademacs-ebbc6a4782c279527c52d6b1d8b379517aeec2d5.tar.gz
emacs-ebbc6a4782c279527c52d6b1d8b379517aeec2d5.zip
Some progress towards starting with PWD deleted. (Bug#18851)
* src/buffer.c (init_buffer): Handle get_current_dir_name failures. * lisp/startup.el (normal-top-level, command-line-1): * lisp/minibuffer.el (read-file-name-default): Handle default-directory being nil.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 0b98431eb0e..75a00f0d337 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5285,41 +5285,46 @@ init_buffer (int initialized)
5285 pwd = get_current_dir_name (); 5285 pwd = get_current_dir_name ();
5286 5286
5287 if (!pwd) 5287 if (!pwd)
5288 fatal ("get_current_dir_name: %s\n", strerror (errno));
5289
5290 /* Maybe this should really use some standard subroutine
5291 whose definition is filename syntax dependent. */
5292 len = strlen (pwd);
5293 if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
5294 { 5288 {
5295 /* Grow buffer to add directory separator and '\0'. */ 5289 fprintf (stderr, "Error getting directory: %s", emacs_strerror (errno));
5296 pwd = realloc (pwd, len + 2); 5290 bset_directory (current_buffer, Qnil);
5297 if (!pwd)
5298 fatal ("get_current_dir_name: %s\n", strerror (errno));
5299 pwd[len] = DIRECTORY_SEP;
5300 pwd[len + 1] = '\0';
5301 len++;
5302 } 5291 }
5303 5292 else
5304 /* At this moment, we still don't know how to decode the directory
5305 name. So, we keep the bytes in unibyte form so that file I/O
5306 routines correctly get the original bytes. */
5307 bset_directory (current_buffer, make_unibyte_string (pwd, len));
5308
5309 /* Add /: to the front of the name
5310 if it would otherwise be treated as magic. */
5311 temp = Ffind_file_name_handler (BVAR (current_buffer, directory), Qt);
5312 if (! NILP (temp)
5313 /* If the default dir is just /, TEMP is non-nil
5314 because of the ange-ftp completion handler.
5315 However, it is not necessary to turn / into /:/.
5316 So avoid doing that. */
5317 && strcmp ("/", SSDATA (BVAR (current_buffer, directory))))
5318 { 5293 {
5319 AUTO_STRING (slash_colon, "/:"); 5294 /* Maybe this should really use some standard subroutine
5320 bset_directory (current_buffer, 5295 whose definition is filename syntax dependent. */
5321 concat2 (slash_colon, 5296 len = strlen (pwd);
5322 BVAR (current_buffer, directory))); 5297 if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
5298 {
5299 /* Grow buffer to add directory separator and '\0'. */
5300 pwd = realloc (pwd, len + 2);
5301 if (!pwd)
5302 fatal ("get_current_dir_name: %s\n", strerror (errno));
5303 pwd[len] = DIRECTORY_SEP;
5304 pwd[len + 1] = '\0';
5305 len++;
5306 }
5307
5308 /* At this moment, we still don't know how to decode the directory
5309 name. So, we keep the bytes in unibyte form so that file I/O
5310 routines correctly get the original bytes. */
5311 bset_directory (current_buffer, make_unibyte_string (pwd, len));
5312
5313 /* Add /: to the front of the name
5314 if it would otherwise be treated as magic. */
5315 temp = Ffind_file_name_handler (BVAR (current_buffer, directory), Qt);
5316 if (! NILP (temp)
5317 /* If the default dir is just /, TEMP is non-nil
5318 because of the ange-ftp completion handler.
5319 However, it is not necessary to turn / into /:/.
5320 So avoid doing that. */
5321 && strcmp ("/", SSDATA (BVAR (current_buffer, directory))))
5322 {
5323 AUTO_STRING (slash_colon, "/:");
5324 bset_directory (current_buffer,
5325 concat2 (slash_colon,
5326 BVAR (current_buffer, directory)));
5327 }
5323 } 5328 }
5324 5329
5325 temp = get_minibuffer (0); 5330 temp = get_minibuffer (0);