Commit d6c180c4 authored by Juanma Barranquero's avatar Juanma Barranquero

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'.
parent ecd43cb9
2008-10-24 Juanma Barranquero <lekktu@gmail.com>
* NEWS: New function `locate-user-emacs-file'.
2008-10-18 Ulrich Mueller <ulm@gentoo.org>
* MACHINES: Add section for SuperH.
......
......@@ -1636,6 +1636,10 @@ the match data.
`serial-process-configure' provide a Lisp interface to the new serial
port support (see Emacs changes, above).
*** `locate-user-emacs-file' helps packages to select the appropriate
place to save user-specific files. It defaults to `user-emacs-directory'
unless the file already exists at $HOME.
** Miscellaneous new variables
+++
......
2008-10-24 Juanma Barranquero <lekktu@gmail.com>
* 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.
2008-10-23 Juanma Barranquero <lekktu@gmail.com>
* edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.
......
......@@ -296,13 +296,7 @@ See also `save-completions-retention-time'."
:group 'completion)
(defcustom save-completions-file-name
(let ((olddef (convert-standard-filename "~/.completions")))
(cond
((file-readable-p olddef) olddef)
((file-directory-p user-emacs-directory)
(convert-standard-filename
(expand-file-name "completions" user-emacs-directory)))
(t olddef)))
(locate-user-emacs-file "completions" ".completions")
"The filename to save completions to."
:type 'file
:group 'completion)
......
......@@ -354,9 +354,7 @@ See `add-submenu' for documentation."
;; :group 'filesets)
(defcustom filesets-menu-cache-file
(if (featurep 'xemacs)
"~/.xemacs/filesets-cache.el"
(concat user-emacs-directory "filesets-cache.el"))
(locate-user-emacs-file "filesets-cache.el")
"File to be used for saving the filesets menu between sessions.
Set this to \"\", to disable caching of menus.
Don't forget to check out `filesets-menu-ensure-use-cached'."
......
......@@ -164,7 +164,7 @@
:prefix "image-dired-"
:group 'multimedia)
(defcustom image-dired-dir (concat user-emacs-directory "image-dired/")
(defcustom image-dired-dir (locate-user-emacs-file "image-dired/")
"Directory where thumbnail images are stored."
:type 'string
:group 'image-dired)
......@@ -186,19 +186,19 @@ that allows sharing of thumbnails across different programs."
:group 'image-dired)
(defcustom image-dired-db-file
(concat user-emacs-directory "image-dired/.image-dired_db")
(locate-user-emacs-file "image-dired/.image-dired_db")
"Database file where file names and their associated tags are stored."
:type 'string
:group 'image-dired)
(defcustom image-dired-temp-image-file
(concat user-emacs-directory "image-dired/.image-dired_temp")
(locate-user-emacs-file "image-dired/.image-dired_temp")
"Name of temporary image file used by various commands."
:type 'string
:group 'image-dired)
(defcustom image-dired-gallery-dir
(concat user-emacs-directory "image-dired/.image-dired_gallery")
(locate-user-emacs-file "image-dired/.image-dired_gallery")
"Directory to store generated gallery html pages.
This path needs to be \"shared\" to the public so that it can access
the index.html page that image-dired creates."
......@@ -343,7 +343,7 @@ original image file name and %t which is replaced by
:group 'image-dired)
(defcustom image-dired-temp-rotate-image-file
(concat user-emacs-directory "image-dired/.image-dired_rotate_temp")
(locate-user-emacs-file "image-dired/.image-dired_rotate_temp")
"Temporary file for rotate operations."
:type 'string
:group 'image-dired)
......
......@@ -65,7 +65,7 @@
"Number of high scores to keep")
(defvar gamegrid-user-score-file-directory
(concat user-emacs-directory "games")
(locate-user-emacs-file "games/")
"A directory for game scores which can't be shared.
If Emacs was built without support for shared game scores, then this
directory will be used.")
......
......@@ -96,15 +96,7 @@ minibuffer histories, such as `compile-command' or `kill-ring'."
:group 'savehist)
(defcustom savehist-file
(cond
;; Backward compatibility with previous versions of savehist.
((file-exists-p "~/.emacs-history") "~/.emacs-history")
((and (not (featurep 'xemacs)) (file-directory-p user-emacs-directory))
(concat user-emacs-directory "history"))
((and (featurep 'xemacs) (file-directory-p "~/.xemacs/"))
"~/.xemacs/history")
;; For users without `~/.emacs.d/' or `~/.xemacs/'.
(t (convert-standard-filename "~/.emacs-history")))
(locate-user-emacs-file "history" ".emacs-history")
"*File name where minibuffer history is saved to and loaded from.
The minibuffer history is a series of Lisp expressions loaded
automatically when `savehist-mode' is turned on. See `savehist-mode'
......
......@@ -111,7 +111,7 @@ If set, the server accepts remote connections; otherwise it is local."
:version "22.1")
(put 'server-host 'risky-local-variable t)
(defcustom server-auth-dir (concat user-emacs-directory "server/")
(defcustom server-auth-dir (locate-user-emacs-file "server/")
"Directory for server authentication files."
:group 'server
:type 'directory
......
......@@ -350,9 +350,9 @@ init file is read, in case it sets `mail-host-address'."
(defcustom auto-save-list-file-prefix
(cond ((eq system-type 'ms-dos)
;; MS-DOS cannot have initial dot, and allows only 8.3 names
(concat user-emacs-directory "auto-save.list/_s"))
(locate-user-emacs-file "auto-save.list/_s"))
(t
(concat user-emacs-directory "auto-save-list/.saves-")))
(locate-user-emacs-file "auto-save-list/.saves-")))
"Prefix for generating `auto-save-list-file-name'.
This is used after reading your `.emacs' file to initialize
`auto-save-list-file-name', by appending Emacs's pid and the system name,
......
......@@ -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.
......
......@@ -65,7 +65,7 @@
:version "22.1"
:group 'multimedia)
(defcustom thumbs-thumbsdir (concat user-emacs-directory "thumbs")
(defcustom thumbs-thumbsdir (locate-user-emacs-file "thumbs")
"*Directory to store thumbnails."
:type 'directory
:group 'thumbs)
......
......@@ -625,7 +625,7 @@ with some explanatory links."
(defun tutorial--saved-dir ()
"Directory to which tutorials are saved."
(expand-file-name "tutorial" user-emacs-directory))
(locate-user-emacs-file "tutorial/"))
(defun tutorial--saved-file ()
"File name in which to save tutorials."
......
2008-10-24 Juanma Barranquero <lekktu@gmail.com>
* url.el (url-configuration-directory): Use `locate-user-emacs-file'.
2008-10-20 İsmail Dönmez <ismail@namtrac.org> (tiny change)
* url-auth.el (url-basic-auth): Encode password string.
......@@ -769,8 +773,7 @@
2005-06-14 Juanma Barranquero <lekktu@gmail.com>
* url-history.el (url-completion-function): Follow error
conventions.
* url-history.el (url-completion-function): Follow error conventions.
2005-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
......
......@@ -45,12 +45,8 @@
(require 'url-util)
;; FIXME convert-standard-filename?
(defcustom url-configuration-directory
(if (and (file-directory-p user-emacs-directory)
(not (file-directory-p "~/.url")))
(expand-file-name "url" user-emacs-directory)
"~/.url")
(locate-user-emacs-file ".url/" "url/")
"Directory used by the URL package for cookies, history, etc."
:type 'directory
:group 'url)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment