diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-10-29 22:14:16 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-10-29 22:14:16 -0400 |
commit | 53b39e8977941c6b60deeeca3c0e54da9ec7961a (patch) | |
tree | a8cc06eca243be50e6e018a8df438ac3a85ab7dd /lisp/files.el | |
parent | 195ee2f0a990771753330ee912581da957eee034 (diff) | |
download | emacs-53b39e8977941c6b60deeeca3c0e54da9ec7961a.tar.gz |
* lisp/subr.el (custom-declare-variable-early): Remove function.
(custom-declare-variable-list): Remove var.
(error, user-error): Remove `while' loop.
(read-quoted-char-radix, read-quoted-char): Move to simple.el.
(user-emacs-directory-warning, locate-user-emacs-file):
Move to files.el.
* lisp/simple.el (read-quoted-char-radix, read-quoted-char):
* lisp/files.el (user-emacs-directory-warning, locate-user-emacs-file):
Move from subr.el.
* lisp/custom.el (custom-declare-variable-list): Don't process
custom-declare-variable-list.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el index cf3356014a1..d44401b4302 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -916,6 +916,57 @@ which we're looking." (setq file nil)))) (if root (file-name-as-directory root)))) +(defcustom user-emacs-directory-warning t + "Non-nil means warn if cannot access `user-emacs-directory'. +Set this to nil at your own risk..." + :type 'boolean + :group 'initialization + :version "24.4") + +(defun locate-user-emacs-file (new-name &optional old-name) + "Return an absolute per-user Emacs-specific file name. +If NEW-NAME exists in `user-emacs-directory', return it. +Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME. +Else return NEW-NAME in `user-emacs-directory', creating the +directory if it does not exist." + (convert-standard-filename + (let* ((home (concat "~" (or init-file-user ""))) + (at-home (and old-name (expand-file-name old-name home))) + (bestname (abbreviate-file-name + (expand-file-name new-name user-emacs-directory)))) + (if (and at-home (not (file-readable-p bestname)) + (file-readable-p at-home)) + at-home + ;; Make sure `user-emacs-directory' exists, + ;; unless we're in batch mode or dumping Emacs. + (or noninteractive + purify-flag + (let (errtype) + (if (file-directory-p user-emacs-directory) + (or (file-accessible-directory-p user-emacs-directory) + (setq errtype "access")) + (let ((umask (default-file-modes))) + (unwind-protect + (progn + (set-default-file-modes ?\700) + (condition-case nil + (make-directory user-emacs-directory) + (error (setq errtype "create")))) + (set-default-file-modes umask)))) + (when (and errtype + user-emacs-directory-warning + (not (get 'user-emacs-directory-warning 'this-session))) + ;; Only warn once per Emacs session. + (put 'user-emacs-directory-warning 'this-session t) + (display-warning 'initialization + (format "\ +Unable to %s `user-emacs-directory' (%s). +Any data that would normally be written there may be lost! +If you never want to see this message again, +customize the variable `user-emacs-directory-warning'." + errtype user-emacs-directory))))) + bestname)))) + (defun executable-find (command) "Search for COMMAND in `exec-path' and return the absolute file name. |