summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2002-02-02 12:49:58 +0000
committerEli Zaretskii <eliz@gnu.org>2002-02-02 12:49:58 +0000
commit2308fe2716ddaa9538100f0d95196a879c69d282 (patch)
tree0563ad5f2b68613afa10976a11941692cb636ece /lisp
parent4fbcc9b1eb28834edf159ea5fd91e255a9aded3c (diff)
downloademacs-2308fe2716ddaa9538100f0d95196a879c69d282.tar.gz
emacs-2308fe2716ddaa9538100f0d95196a879c69d282.tar.bz2
emacs-2308fe2716ddaa9538100f0d95196a879c69d282.zip
(enable-command): If Emacs was invoked as "emacs -q",
don't alter the user's ~/.emacs. (disable-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"
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/novice.el54
2 files changed, 47 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 42562bb143d..6ae25cf0190 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2002-02-02 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * novice.el (enable-command): If Emacs was invoked as "emacs -q",
+ don't alter the user's ~/.emacs.
+ (disable-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): Undo half of last change.
diff --git a/lisp/novice.el b/lisp/novice.el
index c22e685aef3..2d1481fb56a 100644
--- a/lisp/novice.el
+++ b/lisp/novice.el
@@ -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,17 +146,33 @@ to future sessions."
(if (not (commandp command))
(error "Invalid command name `%s'" command))
(put command 'disabled t)
- (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))))
- (goto-char (point-max))
- (insert "\n(put '" (symbol-name command) " 'disabled t)\n")
- (save-buffer)))
+ (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 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))))
+ (goto-char (point-max))
+ (insert "\n(put '" (symbol-name command) " 'disabled t)\n")
+ (save-buffer))))
(provide 'novice)