changeset 37899:3c9f67eea2f9

(enable-command): If user-init-file is nil or does not exist, default to "~/.emacs" (~/_emacs on DOS and, maybe, Windows).
author Eli Zaretskii <eliz@gnu.org>
date Sun, 27 May 2001 06:16:19 +0000
parents 3a5c80f7f0bd
children 2f01c1cfec1c
files lisp/novice.el
diffstat 1 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/novice.el	Sat May 26 17:16:40 2001 +0000
+++ b/lisp/novice.el	Sun May 27 06:16:19 2001 +0000
@@ -107,19 +107,27 @@
 to future sessions."
   (interactive "CEnable command: ")
   (put command 'disabled nil)
-  (save-excursion
-   (set-buffer (find-file-noselect
-		(substitute-in-file-name user-init-file)))
-   (goto-char (point-min))
-   (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
-       (delete-region
-	(progn (beginning-of-line) (point))
-	(progn (forward-line 1) (point))))
-   ;; Explicitly enable, in case this command is disabled by default
-   ;; or in case the code we deleted was actually a comment.
-   (goto-char (point-max))
-   (insert "\n(put '" (symbol-name command) " 'disabled nil)\n")
-   (save-buffer)))
+  (let ((init-file user-init-file))
+    (when (or (not (stringp init-file))
+	      (not (file-exists-p init-file)))
+      (setq init-file (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs"))
+      (if (and (not (file-exists-p init-file))
+	       (eq system-type 'windows-nt)
+	       (file-exists-p "~/_emacs"))
+	  (setq init-file "~/_emacs")))
+    (save-excursion
+      (set-buffer (find-file-noselect
+		   (substitute-in-file-name init-file)))
+      (goto-char (point-min))
+      (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
+	  (delete-region
+	   (progn (beginning-of-line) (point))
+	   (progn (forward-line 1) (point))))
+      ;; Explicitly enable, in case this command is disabled by default
+      ;; or in case the code we deleted was actually a comment.
+      (goto-char (point-max))
+      (insert "\n(put '" (symbol-name command) " 'disabled nil)\n")
+      (save-buffer))))
 
 ;;;###autoload
 (defun disable-command (command)