aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2008-10-24 09:39:27 +0000
committerJuanma Barranquero2008-10-24 09:39:27 +0000
commitd6c180c46bcd0e492695aefee576d51a7bdf32e6 (patch)
tree5c234b6bd9501b91148dc39777f612b9fc1cadd8
parentecd43cb971723a8573afaa4ba6c8d50de7aa6db5 (diff)
downloademacs-d6c180c46bcd0e492695aefee576d51a7bdf32e6.tar.gz
emacs-d6c180c46bcd0e492695aefee576d51a7bdf32e6.zip
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'.
-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 @@
12008-10-24 Juanma Barranquero <lekktu@gmail.com>
2
3 * NEWS: New function `locate-user-emacs-file'.
4
12008-10-18 Ulrich Mueller <ulm@gentoo.org> 52008-10-18 Ulrich Mueller <ulm@gentoo.org>
2 6
3 * MACHINES: Add section for SuperH. 7 * 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.
1636`serial-process-configure' provide a Lisp interface to the new serial 1636`serial-process-configure' provide a Lisp interface to the new serial
1637port support (see Emacs changes, above). 1637port support (see Emacs changes, above).
1638 1638
1639*** `locate-user-emacs-file' helps packages to select the appropriate
1640place to save user-specific files. It defaults to `user-emacs-directory'
1641unless the file already exists at $HOME.
1642
1639** Miscellaneous new variables 1643** Miscellaneous new variables
1640 1644
1641+++ 1645+++
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c0f03a63d2c..c115c29d93b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,20 @@
12008-10-24 Juanma Barranquero <lekktu@gmail.com>
2
3 * subr.el (locate-user-emacs-file): New function.
4 (user-emacs-directory): Mention it in docstring.
5
6 * completion.el (save-completions-file-name):
7 * filesets.el (filesets-menu-cache-file):
8 * image-dired.el (image-dired-dir, image-dired-db-file)
9 (image-dired-temp-image-file, image-dired-gallery-dir)
10 (image-dired-temp-rotate-image-file):
11 * savehist.el (savehist-file):
12 * server.el (server-auth-dir):
13 * startup.el (auto-save-list-file-prefix):
14 * thumbs.el (thumbs-thumbsdir):
15 * tutorial.el (tutorial--saved-dir):
16 * play/gamegrid.el (gamegrid-user-score-file-directory): Use it.
17
12008-10-23 Juanma Barranquero <lekktu@gmail.com> 182008-10-23 Juanma Barranquero <lekktu@gmail.com>
2 19
3 * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos. 20 * 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'."
296 :group 'completion) 296 :group 'completion)
297 297
298(defcustom save-completions-file-name 298(defcustom save-completions-file-name
299 (let ((olddef (convert-standard-filename "~/.completions"))) 299 (locate-user-emacs-file "completions" ".completions")
300 (cond
301 ((file-readable-p olddef) olddef)
302 ((file-directory-p user-emacs-directory)
303 (convert-standard-filename
304 (expand-file-name "completions" user-emacs-directory)))
305 (t olddef)))
306 "The filename to save completions to." 300 "The filename to save completions to."
307 :type 'file 301 :type 'file
308 :group 'completion) 302 :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."
354;; :group 'filesets) 354;; :group 'filesets)
355 355
356(defcustom filesets-menu-cache-file 356(defcustom filesets-menu-cache-file
357 (if (featurep 'xemacs) 357 (locate-user-emacs-file "filesets-cache.el")
358 "~/.xemacs/filesets-cache.el"
359 (concat user-emacs-directory "filesets-cache.el"))
360 "File to be used for saving the filesets menu between sessions. 358 "File to be used for saving the filesets menu between sessions.
361Set this to \"\", to disable caching of menus. 359Set this to \"\", to disable caching of menus.
362Don't forget to check out `filesets-menu-ensure-use-cached'." 360Don'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 @@
164 :prefix "image-dired-" 164 :prefix "image-dired-"
165 :group 'multimedia) 165 :group 'multimedia)
166 166
167(defcustom image-dired-dir (concat user-emacs-directory "image-dired/") 167(defcustom image-dired-dir (locate-user-emacs-file "image-dired/")
168 "Directory where thumbnail images are stored." 168 "Directory where thumbnail images are stored."
169 :type 'string 169 :type 'string
170 :group 'image-dired) 170 :group 'image-dired)
@@ -186,19 +186,19 @@ that allows sharing of thumbnails across different programs."
186 :group 'image-dired) 186 :group 'image-dired)
187 187
188(defcustom image-dired-db-file 188(defcustom image-dired-db-file
189 (concat user-emacs-directory "image-dired/.image-dired_db") 189 (locate-user-emacs-file "image-dired/.image-dired_db")
190 "Database file where file names and their associated tags are stored." 190 "Database file where file names and their associated tags are stored."
191 :type 'string 191 :type 'string
192 :group 'image-dired) 192 :group 'image-dired)
193 193
194(defcustom image-dired-temp-image-file 194(defcustom image-dired-temp-image-file
195 (concat user-emacs-directory "image-dired/.image-dired_temp") 195 (locate-user-emacs-file "image-dired/.image-dired_temp")
196 "Name of temporary image file used by various commands." 196 "Name of temporary image file used by various commands."
197 :type 'string 197 :type 'string
198 :group 'image-dired) 198 :group 'image-dired)
199 199
200(defcustom image-dired-gallery-dir 200(defcustom image-dired-gallery-dir
201 (concat user-emacs-directory "image-dired/.image-dired_gallery") 201 (locate-user-emacs-file "image-dired/.image-dired_gallery")
202 "Directory to store generated gallery html pages. 202 "Directory to store generated gallery html pages.
203This path needs to be \"shared\" to the public so that it can access 203This path needs to be \"shared\" to the public so that it can access
204the index.html page that image-dired creates." 204the index.html page that image-dired creates."
@@ -343,7 +343,7 @@ original image file name and %t which is replaced by
343 :group 'image-dired) 343 :group 'image-dired)
344 344
345(defcustom image-dired-temp-rotate-image-file 345(defcustom image-dired-temp-rotate-image-file
346 (concat user-emacs-directory "image-dired/.image-dired_rotate_temp") 346 (locate-user-emacs-file "image-dired/.image-dired_rotate_temp")
347 "Temporary file for rotate operations." 347 "Temporary file for rotate operations."
348 :type 'string 348 :type 'string
349 :group 'image-dired) 349 :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 @@
65 "Number of high scores to keep") 65 "Number of high scores to keep")
66 66
67(defvar gamegrid-user-score-file-directory 67(defvar gamegrid-user-score-file-directory
68 (concat user-emacs-directory "games") 68 (locate-user-emacs-file "games/")
69 "A directory for game scores which can't be shared. 69 "A directory for game scores which can't be shared.
70If Emacs was built without support for shared game scores, then this 70If Emacs was built without support for shared game scores, then this
71directory will be used.") 71directory 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'."
96 :group 'savehist) 96 :group 'savehist)
97 97
98(defcustom savehist-file 98(defcustom savehist-file
99 (cond 99 (locate-user-emacs-file "history" ".emacs-history")
100 ;; Backward compatibility with previous versions of savehist.
101 ((file-exists-p "~/.emacs-history") "~/.emacs-history")
102 ((and (not (featurep 'xemacs)) (file-directory-p user-emacs-directory))
103 (concat user-emacs-directory "history"))
104 ((and (featurep 'xemacs) (file-directory-p "~/.xemacs/"))
105 "~/.xemacs/history")
106 ;; For users without `~/.emacs.d/' or `~/.xemacs/'.
107 (t (convert-standard-filename "~/.emacs-history")))
108 "*File name where minibuffer history is saved to and loaded from. 100 "*File name where minibuffer history is saved to and loaded from.
109The minibuffer history is a series of Lisp expressions loaded 101The minibuffer history is a series of Lisp expressions loaded
110automatically when `savehist-mode' is turned on. See `savehist-mode' 102automatically 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."
111 :version "22.1") 111 :version "22.1")
112(put 'server-host 'risky-local-variable t) 112(put 'server-host 'risky-local-variable t)
113 113
114(defcustom server-auth-dir (concat user-emacs-directory "server/") 114(defcustom server-auth-dir (locate-user-emacs-file "server/")
115 "Directory for server authentication files." 115 "Directory for server authentication files."
116 :group 'server 116 :group 'server
117 :type 'directory 117 :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'."
350(defcustom auto-save-list-file-prefix 350(defcustom auto-save-list-file-prefix
351 (cond ((eq system-type 'ms-dos) 351 (cond ((eq system-type 'ms-dos)
352 ;; MS-DOS cannot have initial dot, and allows only 8.3 names 352 ;; MS-DOS cannot have initial dot, and allows only 8.3 names
353 (concat user-emacs-directory "auto-save.list/_s")) 353 (locate-user-emacs-file "auto-save.list/_s"))
354 (t 354 (t
355 (concat user-emacs-directory "auto-save-list/.saves-"))) 355 (locate-user-emacs-file "auto-save-list/.saves-")))
356 "Prefix for generating `auto-save-list-file-name'. 356 "Prefix for generating `auto-save-list-file-name'.
357This is used after reading your `.emacs' file to initialize 357This is used after reading your `.emacs' file to initialize
358`auto-save-list-file-name', by appending Emacs's pid and the system name, 358`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.")
2156 "~/.emacs.d/") 2156 "~/.emacs.d/")
2157 "Directory beneath which additional per-user Emacs-specific files are placed. 2157 "Directory beneath which additional per-user Emacs-specific files are placed.
2158Various programs in Emacs store information in this directory. 2158Various programs in Emacs store information in this directory.
2159Note that this should end with a directory separator.") 2159Note that this should end with a directory separator.
2160See also `locate-user-emacs-file'.")
2161
2162(defun locate-user-emacs-file (new-name &optional old-name)
2163 "Return an absolute per-user Emacs-specific file name.
2164If OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
2165Else return NEW-NAME in `user-emacs-directory', creating the
2166directory if it does not exist."
2167 (convert-standard-filename
2168 (let* ((home (concat "~" (or init-file-user "")))
2169 (at-home (and old-name (expand-file-name old-name home))))
2170 (if (and at-home (file-readable-p at-home))
2171 at-home
2172 (unless (or purify-flag ;; don't create dir while dumping
2173 (file-accessible-directory-p
2174 (directory-file-name user-emacs-directory)))
2175 (make-directory user-emacs-directory t)) ;; don't catch errors
2176 (expand-file-name new-name user-emacs-directory)))))
2160 2177
2161 2178
2162;;;; Misc. useful functions. 2179;;;; 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 @@
65 :version "22.1" 65 :version "22.1"
66 :group 'multimedia) 66 :group 'multimedia)
67 67
68(defcustom thumbs-thumbsdir (concat user-emacs-directory "thumbs") 68(defcustom thumbs-thumbsdir (locate-user-emacs-file "thumbs")
69 "*Directory to store thumbnails." 69 "*Directory to store thumbnails."
70 :type 'directory 70 :type 'directory
71 :group 'thumbs) 71 :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."
625 625
626(defun tutorial--saved-dir () 626(defun tutorial--saved-dir ()
627 "Directory to which tutorials are saved." 627 "Directory to which tutorials are saved."
628 (expand-file-name "tutorial" user-emacs-directory)) 628 (locate-user-emacs-file "tutorial/"))
629 629
630(defun tutorial--saved-file () 630(defun tutorial--saved-file ()
631 "File name in which to save tutorials." 631 "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 @@
12008-10-24 Juanma Barranquero <lekktu@gmail.com>
2
3 * url.el (url-configuration-directory): Use `locate-user-emacs-file'.
4
12008-10-20 İsmail Dönmez <ismail@namtrac.org> (tiny change) 52008-10-20 İsmail Dönmez <ismail@namtrac.org> (tiny change)
2 6
3 * url-auth.el (url-basic-auth): Encode password string. 7 * url-auth.el (url-basic-auth): Encode password string.
@@ -769,8 +773,7 @@
769 773
7702005-06-14 Juanma Barranquero <lekktu@gmail.com> 7742005-06-14 Juanma Barranquero <lekktu@gmail.com>
771 775
772 * url-history.el (url-completion-function): Follow error 776 * url-history.el (url-completion-function): Follow error conventions.
773 conventions.
774 777
7752005-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 7782005-06-13 Stefan Monnier <monnier@iro.umontreal.ca>
776 779
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 @@
45(require 'url-util) 45(require 'url-util)
46 46
47 47
48;; FIXME convert-standard-filename?
49(defcustom url-configuration-directory 48(defcustom url-configuration-directory
50 (if (and (file-directory-p user-emacs-directory) 49 (locate-user-emacs-file ".url/" "url/")
51 (not (file-directory-p "~/.url")))
52 (expand-file-name "url" user-emacs-directory)
53 "~/.url")
54 "Directory used by the URL package for cookies, history, etc." 50 "Directory used by the URL package for cookies, history, etc."
55 :type 'directory 51 :type 'directory
56 :group 'url) 52 :group 'url)