aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2002-02-02 12:49:58 +0000
committerEli Zaretskii2002-02-02 12:49:58 +0000
commit2308fe2716ddaa9538100f0d95196a879c69d282 (patch)
tree0563ad5f2b68613afa10976a11941692cb636ece
parent4fbcc9b1eb28834edf159ea5fd91e255a9aded3c (diff)
downloademacs-2308fe2716ddaa9538100f0d95196a879c69d282.tar.gz
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"
-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 @@
12002-02-02 Eli Zaretskii <eliz@is.elta.co.il>
2
3 * novice.el (enable-command): If Emacs was invoked as "emacs -q",
4 don't alter the user's ~/.emacs.
5 (disable-command): If user-init-file is nil or does not exist,
6 default to "~/.emacs" (~/_emacs on DOS and, maybe, Windows). But
7 don't alter the init file if Emacs was invoked as "emacs -q"
8
12002-02-01 Stefan Monnier <monnier@cs.yale.edu> 92002-02-01 Stefan Monnier <monnier@cs.yale.edu>
2 10
3 * mail/sendmail.el (mail-mode): Undo half of last change. 11 * 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
107to future sessions." 107to future sessions."
108 (interactive "CEnable command: ") 108 (interactive "CEnable command: ")
109 (put command 'disabled nil) 109 (put command 'disabled nil)
110 (let ((init-file user-init-file)) 110 (let ((init-file user-init-file)
111 (when (or (not (stringp init-file)) 111 (default-init-file
112 (not (file-exists-p init-file))) 112 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
113 (setq init-file (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")) 113 (when (null init-file)
114 (if (or (file-exists-p default-init-file)
115 (and (eq system-type 'windows-nt)
116 (file-exists-p "~/_emacs")))
117 ;; Started with -q, i.e. the file containing
118 ;; enabled/disabled commands hasn't been read. Saving
119 ;; settings there would overwrite other settings.
120 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
121 (setq init-file default-init-file)
114 (if (and (not (file-exists-p init-file)) 122 (if (and (not (file-exists-p init-file))
115 (eq system-type 'windows-nt) 123 (eq system-type 'windows-nt)
116 (file-exists-p "~/_emacs")) 124 (file-exists-p "~/_emacs"))
@@ -138,17 +146,33 @@ to future sessions."
138 (if (not (commandp command)) 146 (if (not (commandp command))
139 (error "Invalid command name `%s'" command)) 147 (error "Invalid command name `%s'" command))
140 (put command 'disabled t) 148 (put command 'disabled t)
141 (save-excursion 149 (let ((init-file user-init-file)
142 (set-buffer (find-file-noselect 150 (default-init-file
143 (substitute-in-file-name user-init-file))) 151 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
144 (goto-char (point-min)) 152 (when (null init-file)
145 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t) 153 (if (or (file-exists-p default-init-file)
146 (delete-region 154 (and (eq system-type 'windows-nt)
147 (progn (beginning-of-line) (point)) 155 (file-exists-p "~/_emacs")))
148 (progn (forward-line 1) (point)))) 156 ;; Started with -q, i.e. the file containing
149 (goto-char (point-max)) 157 ;; enabled/disabled commands hasn't been read. Saving
150 (insert "\n(put '" (symbol-name command) " 'disabled t)\n") 158 ;; settings there would overwrite other settings.
151 (save-buffer))) 159 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
160 (setq init-file default-init-file)
161 (if (and (not (file-exists-p init-file))
162 (eq system-type 'windows-nt)
163 (file-exists-p "~/_emacs"))
164 (setq init-file "~/_emacs")))
165 (save-excursion
166 (set-buffer (find-file-noselect
167 (substitute-in-file-name init-file)))
168 (goto-char (point-min))
169 (if (search-forward (concat "(put '" (symbol-name command) " ") nil t)
170 (delete-region
171 (progn (beginning-of-line) (point))
172 (progn (forward-line 1) (point))))
173 (goto-char (point-max))
174 (insert "\n(put '" (symbol-name command) " 'disabled t)\n")
175 (save-buffer))))
152 176
153(provide 'novice) 177(provide 'novice)
154 178