107 |
to future sessions." |
to future sessions." |
108 |
(interactive "CEnable command: ") |
(interactive "CEnable command: ") |
109 |
(put command 'disabled nil) |
(put command 'disabled nil) |
110 |
(let ((init-file user-init-file)) |
(let ((init-file user-init-file) |
111 |
(when (or (not (stringp init-file)) |
(default-init-file |
112 |
(not (file-exists-p init-file))) |
(if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs"))) |
113 |
(setq init-file (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")) |
(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) |
122 |
(if (and (not (file-exists-p init-file)) |
(if (and (not (file-exists-p init-file)) |
123 |
(eq system-type 'windows-nt) |
(eq system-type 'windows-nt) |
124 |
(file-exists-p "~/_emacs")) |
(file-exists-p "~/_emacs")) |
146 |
(if (not (commandp command)) |
(if (not (commandp command)) |
147 |
(error "Invalid command name `%s'" command)) |
(error "Invalid command name `%s'" command)) |
148 |
(put command 'disabled t) |
(put command 'disabled t) |
149 |
(save-excursion |
(let ((init-file user-init-file) |
150 |
(set-buffer (find-file-noselect |
(default-init-file |
151 |
(substitute-in-file-name user-init-file))) |
(if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs"))) |
152 |
(goto-char (point-min)) |
(when (null init-file) |
153 |
(if (search-forward (concat "(put '" (symbol-name command) " ") nil t) |
(if (or (file-exists-p default-init-file) |
154 |
(delete-region |
(and (eq system-type 'windows-nt) |
155 |
(progn (beginning-of-line) (point)) |
(file-exists-p "~/_emacs"))) |
156 |
(progn (forward-line 1) (point)))) |
;; Started with -q, i.e. the file containing |
157 |
(goto-char (point-max)) |
;; enabled/disabled commands hasn't been read. Saving |
158 |
(insert "\n(put '" (symbol-name command) " 'disabled t)\n") |
;; settings there would overwrite other settings. |
159 |
(save-buffer))) |
(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)))) |
176 |
|
|
177 |
(provide 'novice) |
(provide 'novice) |
178 |
|
|