;; describes the directory linked to, not FOO itself.
(or (equal (file-attributes
(concat (file-name-as-directory pwd) "."))
- (file-attributes
- (concat (file-name-as-directory default-directory)
- ".")))
+ (if default-directory
+ (file-attributes
+ (concat (file-name-as-directory default-directory)
+ "."))))
(setq process-environment
(delete (concat "PWD=" pwd)
process-environment)))))
(mapcar (lambda (dir)
(decode-coding-string dir coding t))
charset-map-path))))
- (setq default-directory (abbreviate-file-name default-directory))
+ (if default-directory
+ (setq default-directory (abbreviate-file-name default-directory))
+ ;; FIXME this does not get shown.
+ ;; If after (command-line), it is shown, but if command-line
+ ;; changed the buffer (eg found a file), it applies to that
+ ;; buffer, not *scratch*.
+ (display-warning 'initialization "Error setting default-directory"))
(let ((old-face-font-rescale-alist face-font-rescale-alist))
(unwind-protect
(command-line)
;; Do this again, in case .emacs defined more abbreviations.
- (setq default-directory (abbreviate-file-name default-directory))
+ (if default-directory
+ (setq default-directory (abbreviate-file-name default-directory)))
;; Specify the file for recording all the auto save files of this session.
;; This is used by recover-session.
(or auto-save-list-file-name
;; to zero when `process-file-arg' returns.
(process-file-arg
(lambda (name)
- (let* ((file (expand-file-name
+ ;; If a relative filename was specified and
+ ;; command-line-default-directory is nil,
+ ;; silently drop that argument.
+ ;; This can only happen if PWD is deleted.
+ ;; The warning about setting default-directory will
+ ;; clue you in.
+ (when (and (or dir (file-name-absolute-p name))
+ (let* ((file (expand-file-name
(command-line-normalize-file-name name)
dir))
- (buf (find-file-noselect file)))
- (setq displayable-buffers (cons buf displayable-buffers))
- (with-current-buffer buf
- (unless (zerop line)
- (goto-char (point-min))
- (forward-line (1- line)))
- (setq line 0)
- (unless (< column 1)
- (move-to-column (1- column)))
- (setq column 0))))))
+ (buf (find-file-noselect file)))
+ (setq displayable-buffers (cons buf displayable-buffers))
+ (with-current-buffer buf
+ (unless (zerop line)
+ (goto-char (point-min))
+ (forward-line (1- line)))
+ (setq line 0)
+ (unless (< column 1)
+ (move-to-column (1- column)))
+ (setq column 0))))))))
;; Add the long X options to longopts.
(dolist (tem command-line-x-option-alist)
pwd = get_current_dir_name ();
if (!pwd)
- fatal ("get_current_dir_name: %s\n", strerror (errno));
-
- /* Maybe this should really use some standard subroutine
- whose definition is filename syntax dependent. */
- len = strlen (pwd);
- if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
{
- /* Grow buffer to add directory separator and '\0'. */
- pwd = realloc (pwd, len + 2);
- if (!pwd)
- fatal ("get_current_dir_name: %s\n", strerror (errno));
- pwd[len] = DIRECTORY_SEP;
- pwd[len + 1] = '\0';
- len++;
+ fprintf (stderr, "Error getting directory: %s", emacs_strerror (errno));
+ bset_directory (current_buffer, Qnil);
}
-
- /* At this moment, we still don't know how to decode the directory
- name. So, we keep the bytes in unibyte form so that file I/O
- routines correctly get the original bytes. */
- bset_directory (current_buffer, make_unibyte_string (pwd, len));
-
- /* Add /: to the front of the name
- if it would otherwise be treated as magic. */
- temp = Ffind_file_name_handler (BVAR (current_buffer, directory), Qt);
- if (! NILP (temp)
- /* If the default dir is just /, TEMP is non-nil
- because of the ange-ftp completion handler.
- However, it is not necessary to turn / into /:/.
- So avoid doing that. */
- && strcmp ("/", SSDATA (BVAR (current_buffer, directory))))
+ else
{
- AUTO_STRING (slash_colon, "/:");
- bset_directory (current_buffer,
- concat2 (slash_colon,
- BVAR (current_buffer, directory)));
+ /* Maybe this should really use some standard subroutine
+ whose definition is filename syntax dependent. */
+ len = strlen (pwd);
+ if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
+ {
+ /* Grow buffer to add directory separator and '\0'. */
+ pwd = realloc (pwd, len + 2);
+ if (!pwd)
+ fatal ("get_current_dir_name: %s\n", strerror (errno));
+ pwd[len] = DIRECTORY_SEP;
+ pwd[len + 1] = '\0';
+ len++;
+ }
+
+ /* At this moment, we still don't know how to decode the directory
+ name. So, we keep the bytes in unibyte form so that file I/O
+ routines correctly get the original bytes. */
+ bset_directory (current_buffer, make_unibyte_string (pwd, len));
+
+ /* Add /: to the front of the name
+ if it would otherwise be treated as magic. */
+ temp = Ffind_file_name_handler (BVAR (current_buffer, directory), Qt);
+ if (! NILP (temp)
+ /* If the default dir is just /, TEMP is non-nil
+ because of the ange-ftp completion handler.
+ However, it is not necessary to turn / into /:/.
+ So avoid doing that. */
+ && strcmp ("/", SSDATA (BVAR (current_buffer, directory))))
+ {
+ AUTO_STRING (slash_colon, "/:");
+ bset_directory (current_buffer,
+ concat2 (slash_colon,
+ BVAR (current_buffer, directory)));
+ }
}
temp = get_minibuffer (0);