Mercurial > emacs
changeset 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 | 910cbd4e6ade |
children | 83e9dcef8ef7 |
files | etc/ChangeLog etc/NEWS lisp/ChangeLog lisp/completion.el lisp/filesets.el lisp/image-dired.el lisp/play/gamegrid.el lisp/savehist.el lisp/server.el lisp/startup.el lisp/subr.el lisp/thumbs.el lisp/tutorial.el lisp/url/ChangeLog lisp/url/url.el |
diffstat | 15 files changed, 63 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/etc/ChangeLog Fri Oct 24 07:23:34 2008 +0000 +++ b/etc/ChangeLog Fri Oct 24 09:39:27 2008 +0000 @@ -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.
--- a/etc/NEWS Fri Oct 24 07:23:34 2008 +0000 +++ b/etc/NEWS Fri Oct 24 09:39:27 2008 +0000 @@ -1636,6 +1636,10 @@ `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 +++
--- a/lisp/ChangeLog Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/ChangeLog Fri Oct 24 09:39:27 2008 +0000 @@ -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.
--- a/lisp/completion.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/completion.el Fri Oct 24 09:39:27 2008 +0000 @@ -296,13 +296,7 @@ :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)
--- a/lisp/filesets.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/filesets.el Fri Oct 24 09:39:27 2008 +0000 @@ -354,9 +354,7 @@ ;; :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'."
--- a/lisp/image-dired.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/image-dired.el Fri Oct 24 09:39:27 2008 +0000 @@ -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 @@ :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 @@ :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)
--- a/lisp/play/gamegrid.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/play/gamegrid.el Fri Oct 24 09:39:27 2008 +0000 @@ -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.")
--- a/lisp/savehist.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/savehist.el Fri Oct 24 09:39:27 2008 +0000 @@ -96,15 +96,7 @@ :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'
--- a/lisp/server.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/server.el Fri Oct 24 09:39:27 2008 +0000 @@ -111,7 +111,7 @@ :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
--- a/lisp/startup.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/startup.el Fri Oct 24 09:39:27 2008 +0000 @@ -350,9 +350,9 @@ (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,
--- 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.
--- a/lisp/thumbs.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/thumbs.el Fri Oct 24 09:39:27 2008 +0000 @@ -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)
--- a/lisp/tutorial.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/tutorial.el Fri Oct 24 09:39:27 2008 +0000 @@ -625,7 +625,7 @@ (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."
--- a/lisp/url/ChangeLog Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/url/ChangeLog Fri Oct 24 09:39:27 2008 +0000 @@ -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>
--- a/lisp/url/url.el Fri Oct 24 07:23:34 2008 +0000 +++ b/lisp/url/url.el Fri Oct 24 09:39:27 2008 +0000 @@ -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)