aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2011-07-11 22:12:07 +0200
committerLars Magne Ingebrigtsen2011-07-11 22:12:07 +0200
commiteab5dc0727f022842e4b4eadd4b0ab0ce4b12939 (patch)
tree10b5da6372e298d284386560e389388e7cca04fb
parent963578d396f018f4cae81bca311882ab4ed15b4f (diff)
downloademacs-eab5dc0727f022842e4b4eadd4b0ab0ce4b12939.tar.gz
emacs-eab5dc0727f022842e4b4eadd4b0ab0ce4b12939.zip
Allow using `customize-save-variable' under Emacs -Q: Set the variable, and give a warning
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/cus-edit.el42
2 files changed, 31 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e024646cd26..f1c36a9feea 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-07-11 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * cus-edit.el (custom-file): Take an optional no-error variable.
4 (customize-save-variable): Set the variable, and give a warning if
5 running under "emacs -q".
6
12011-07-11 Juanma Barranquero <lekktu@gmail.com> 72011-07-11 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * loadhist.el (unload-feature-special-hooks): 9 * loadhist.el (unload-feature-special-hooks):
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 22b7cc6b3fe..d443d6c160c 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1033,7 +1033,11 @@ If given a prefix (or a COMMENT argument), also prompt for a comment."
1033 (put variable 'saved-variable-comment comment))) 1033 (put variable 'saved-variable-comment comment)))
1034 (put variable 'customized-value nil) 1034 (put variable 'customized-value nil)
1035 (put variable 'customized-variable-comment nil) 1035 (put variable 'customized-variable-comment nil)
1036 (custom-save-all) 1036 (if (custom-file t)
1037 (custom-save-all)
1038 (message "Setting `%s' temporarily since \"emacs -q\" would overwrite customizations"
1039 variable)
1040 (set variable value))
1037 value) 1041 value)
1038 1042
1039;; Some parts of Emacs might prompt the user to save customizations, 1043;; Some parts of Emacs might prompt the user to save customizations,
@@ -4403,23 +4407,27 @@ Click on \"More\" \(or position point there and press RETURN)
4403if only the first line of the docstring is shown.")) 4407if only the first line of the docstring is shown."))
4404 :group 'customize) 4408 :group 'customize)
4405 4409
4406(defun custom-file () 4410(defun custom-file (&optional no-error)
4407 "Return the file name for saving customizations." 4411 "Return the file name for saving customizations."
4408 (file-chase-links 4412 (let ((file
4409 (or custom-file 4413 (or custom-file
4410 (let ((user-init-file user-init-file) 4414 (let ((user-init-file user-init-file)
4411 (default-init-file 4415 (default-init-file
4412 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs"))) 4416 (if (eq system-type 'ms-dos) "~/_emacs" "~/.emacs")))
4413 (when (null user-init-file) 4417 (when (null user-init-file)
4414 (if (or (file-exists-p default-init-file) 4418 (if (or (file-exists-p default-init-file)
4415 (and (eq system-type 'windows-nt) 4419 (and (eq system-type 'windows-nt)
4416 (file-exists-p "~/_emacs"))) 4420 (file-exists-p "~/_emacs")))
4417 ;; Started with -q, i.e. the file containing 4421 ;; Started with -q, i.e. the file containing
4418 ;; Custom settings hasn't been read. Saving 4422 ;; Custom settings hasn't been read. Saving
4419 ;; settings there would overwrite other settings. 4423 ;; settings there would overwrite other settings.
4420 (error "Saving settings from \"emacs -q\" would overwrite existing customizations")) 4424 (if no-error
4421 (setq user-init-file default-init-file)) 4425 nil
4422 user-init-file)))) 4426 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
4427 (setq user-init-file default-init-file)))
4428 user-init-file))))
4429 (and file
4430 (file-chase-links file))))
4423 4431
4424;; If recentf-mode is non-nil, this is defined. 4432;; If recentf-mode is non-nil, this is defined.
4425(declare-function recentf-expand-file-name "recentf" (name)) 4433(declare-function recentf-expand-file-name "recentf" (name))