1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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'.
This commit is contained in:
Juanma Barranquero 2008-10-24 09:39:27 +00:00
parent ecd43cb971
commit d6c180c46b
15 changed files with 63 additions and 38 deletions

View file

@ -2156,7 +2156,24 @@ On other systems, this variable is normally always nil.")
"~/.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.