summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/completion.el8
-rw-r--r--lisp/filesets.el4
-rw-r--r--lisp/image-dired.el10
-rw-r--r--lisp/play/gamegrid.el2
-rw-r--r--lisp/savehist.el10
-rw-r--r--lisp/server.el2
-rw-r--r--lisp/startup.el4
-rw-r--r--lisp/subr.el19
-rw-r--r--lisp/thumbs.el2
-rw-r--r--lisp/tutorial.el2
-rw-r--r--lisp/url/ChangeLog7
-rw-r--r--lisp/url/url.el6
15 files changed, 63 insertions, 38 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 2a1ef635321..4afa26a5141 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/etc/NEWS b/etc/NEWS
index d50b9cc4029..70fc968440e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
+++
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c0f03a63d2c..c115c29d93b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,20 @@
+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.
diff --git a/lisp/completion.el b/lisp/completion.el
index 6a5c06a62b6..2f925dd2066 100644
--- a/lisp/completion.el
+++ b/lisp/completion.el
@@ -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)
diff --git a/lisp/filesets.el b/lisp/filesets.el
index 5620d167bdd..6bd6d304175 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -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'."
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 7b0a55de226..f9f1a334e76 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -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)
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 36362f2d49b..824e55043ec 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -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.")
diff --git a/lisp/savehist.el b/lisp/savehist.el
index e3150565d56..55a724452db 100644
--- a/lisp/savehist.el
+++ b/lisp/savehist.el
@@ -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'
diff --git a/lisp/server.el b/lisp/server.el
index 8dfa6d19732..b69965f94a6 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -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
diff --git a/lisp/startup.el b/lisp/startup.el
index 6185cd5975a..84c7341597d 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -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,
diff --git a/lisp/subr.el b/lisp/subr.el
index 40311c4e1f4..5a1f4d42ee2 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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.
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index bb62d4cf6a4..2c4642a4470 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -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)
diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index 93438076b92..456fe5f401e 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -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."
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog
index 7e7ead4dfdb..b27b7255e4d 100644
--- a/lisp/url/ChangeLog
+++ b/lisp/url/ChangeLog
@@ -1,3 +1,7 @@
+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>
diff --git a/lisp/url/url.el b/lisp/url/url.el
index ac7e47d9cc0..c066e39c004 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -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)