]> git.eshelyaron.com Git - emacs.git/commitdiff
(disable-command, enable-command): If user-init-file
authorEli Zaretskii <eliz@gnu.org>
Sat, 2 Feb 2002 13:02:28 +0000 (13:02 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 2 Feb 2002 13:02:28 +0000 (13:02 +0000)
is nil or does not exist, default to "~/.emacs" (~/_emacs on DOS
and, maybe, Windows).  But don't alter the init file if Emacs was
invoked as "emacs -q"

lisp/ChangeLog
lisp/novice.el

index bbe5d92be6df73c41436baf4b6a1f3ac25851226..1e0c685cb310479e1f71a52d04d837e3d7980459 100644 (file)
@@ -1,3 +1,10 @@
+2002-02-02  Eli Zaretskii  <eliz@is.elta.co.il>
+
+       * novice.el (disable-command, enable-command): If user-init-file
+       is nil or does not exist, default to "~/.emacs" (~/_emacs on DOS
+       and, maybe, Windows).  But don't alter the init file if Emacs was
+       invoked as "emacs -q"
+
 2002-02-01  Stefan Monnier  <monnier@cs.yale.edu>
 
        * mail/sendmail.el (mail-mode) <adaptive-fill-first-line-regexp>:
index c22e685aef3bd9e7c4378317ba8ca88fcd17e9ef..4e1645090c11674d64b76c61f9fb47b84170fffd 100644 (file)
@@ -107,10 +107,18 @@ The user's .emacs file is altered so that this will apply
 to future sessions."
   (interactive "CEnable command: ")
   (put command 'disabled nil)
-  (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"))
+  (let ((init-file user-init-file)
+       (default-init-file
+         (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
+    (when (null init-file)
+      (if (or (file-exists-p default-init-file)
+             (and (eq system-type 'windows-nt)
+                  (file-exists-p "~/_emacs")))
+         ;; Started with -q, i.e. the file containing
+         ;; enabled/disabled commands hasn't been read.  Saving
+         ;; settings there would overwrite other settings.
+         (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
+      (setq init-file default-init-file)
       (if (and (not (file-exists-p init-file))
               (eq system-type 'windows-nt)
               (file-exists-p "~/_emacs"))
@@ -138,9 +146,25 @@ to future sessions."
   (if (not (commandp command))
       (error "Invalid command name `%s'" command))
   (put command 'disabled t)
+  (let ((init-file user-init-file)
+       (default-init-file
+         (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
+    (when (null init-file)
+      (if (or (file-exists-p default-init-file)
+             (and (eq system-type 'windows-nt)
+                  (file-exists-p "~/_emacs")))
+         ;; Started with -q, i.e. the file containing
+         ;; enabled/disabled commands hasn't been read.  Saving
+         ;; settings there would overwrite other settings.
+         (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
+      (setq init-file default-init-file)
+      (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 user-init-file)))
+               (substitute-in-file-name init-file)))
    (goto-char (point-min))
    (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
        (delete-region
@@ -148,7 +172,7 @@ to future sessions."
        (progn (forward-line 1) (point))))
    (goto-char (point-max))
    (insert "\n(put '" (symbol-name command) " 'disabled t)\n")
-   (save-buffer)))
+   (save-buffer))))
 
 (provide 'novice)