Mercurial > emacs
diff lisp/subr.el @ 99106:814d2d823dd7
New function `locate-user-emacs-file'.
* subr.el (locate-user-emacs-file): New function.
(user-emacs-directory): Mention it in docstring.
* completion.el (save-completions-file-name):
* filesets.el (filesets-menu-cache-file):
* image-dired.el (image-dired-dir, image-dired-db-file)
(image-dired-temp-image-file, image-dired-gallery-dir)
(image-dired-temp-rotate-image-file):
* savehist.el (savehist-file):
* server.el (server-auth-dir):
* startup.el (auto-save-list-file-prefix):
* thumbs.el (thumbs-thumbsdir):
* tutorial.el (tutorial--saved-dir):
* play/gamegrid.el (gamegrid-user-score-file-directory): Use it.
* url.el (url-configuration-directory): Use `locate-user-emacs-file'.
* NEWS: New function `locate-user-emacs-file'.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 24 Oct 2008 09:39:27 +0000 |
parents | 46d6efaefafc |
children | a96e658622b6 |
line wrap: on
line diff
--- a/lisp/subr.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/subr.el Fri Oct 24 09:39:27 2008 +0000 @@ -2156,7 +2156,24 @@ "~/.emacs.d/") "Directory beneath which additional per-user Emacs-specific files are placed. Various programs in Emacs store information in this directory. -Note that this should end with a directory separator.") +Note that this should end with a directory separator. +See also `locate-user-emacs-file'.") + +(defun locate-user-emacs-file (new-name &optional old-name) + "Return an absolute per-user Emacs-specific file name. +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)))) + (if (and at-home (file-readable-p at-home)) + at-home + (unless (or purify-flag ;; don't create dir while dumping + (file-accessible-directory-p + (directory-file-name user-emacs-directory))) + (make-directory user-emacs-directory t)) ;; don't catch errors + (expand-file-name new-name user-emacs-directory))))) ;;;; Misc. useful functions.