]> git.eshelyaron.com Git - emacs.git/commitdiff
(enable-command): If user-init-file is nil or does not
authorEli Zaretskii <eliz@gnu.org>
Sun, 27 May 2001 06:18:28 +0000 (06:18 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sun, 27 May 2001 06:18:28 +0000 (06:18 +0000)
exist, default to "~/.emacs" (~/_emacs on DOS and, maybe, Windows).

lisp/ChangeLog
lisp/novice.el

index 57184acb695b72e122746be9a5896c4c09fff1b8..7d513375741d205025a7ede905a93a29412bae3b 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-27  Eli Zaretskii  <eliz@is.elta.co.il>
+
+       * novice.el (enable-command): If user-init-file is nil or does not
+       exist, default to "~/.emacs" (~/_emacs on DOS and, maybe, Windows).
+
 2001-05-25  Stefan Monnier  <monnier@cs.yale.edu>
 
        * textmodes/tex-mode.el (tex-mode-syntax-table): Add ^.
index d57aa224a8dacc329b4af0be6d15e3161c3be60a..348774a90fac63b01bfd1f1692d84d61ff577ec5 100644 (file)
@@ -107,19 +107,27 @@ The user's .emacs file is altered so that this will apply
 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)