1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 14:30:50 -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

@ -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> 2008-10-18 Ulrich Mueller <ulm@gentoo.org>
* MACHINES: Add section for SuperH. * MACHINES: Add section for SuperH.

View file

@ -1636,6 +1636,10 @@ the match data.
`serial-process-configure' provide a Lisp interface to the new serial `serial-process-configure' provide a Lisp interface to the new serial
port support (see Emacs changes, above). 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 ** Miscellaneous new variables
+++ +++

View file

@ -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> 2008-10-23 Juanma Barranquero <lekktu@gmail.com>
* edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos. * edmacro.el (edmacro-eight-bits, edmacro-mode): Fix docstring typos.

View file

@ -296,13 +296,7 @@ See also `save-completions-retention-time'."
:group 'completion) :group 'completion)
(defcustom save-completions-file-name (defcustom save-completions-file-name
(let ((olddef (convert-standard-filename "~/.completions"))) (locate-user-emacs-file "completions" ".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)))
"The filename to save completions to." "The filename to save completions to."
:type 'file :type 'file
:group 'completion) :group 'completion)

View file

@ -354,9 +354,7 @@ See `add-submenu' for documentation."
;; :group 'filesets) ;; :group 'filesets)
(defcustom filesets-menu-cache-file (defcustom filesets-menu-cache-file
(if (featurep 'xemacs) (locate-user-emacs-file "filesets-cache.el")
"~/.xemacs/filesets-cache.el"
(concat user-emacs-directory "filesets-cache.el"))
"File to be used for saving the filesets menu between sessions. "File to be used for saving the filesets menu between sessions.
Set this to \"\", to disable caching of menus. Set this to \"\", to disable caching of menus.
Don't forget to check out `filesets-menu-ensure-use-cached'." Don't forget to check out `filesets-menu-ensure-use-cached'."

View file

@ -164,7 +164,7 @@
:prefix "image-dired-" :prefix "image-dired-"
:group 'multimedia) :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." "Directory where thumbnail images are stored."
:type 'string :type 'string
:group 'image-dired) :group 'image-dired)
@ -186,19 +186,19 @@ that allows sharing of thumbnails across different programs."
:group 'image-dired) :group 'image-dired)
(defcustom image-dired-db-file (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." "Database file where file names and their associated tags are stored."
:type 'string :type 'string
:group 'image-dired) :group 'image-dired)
(defcustom image-dired-temp-image-file (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." "Name of temporary image file used by various commands."
:type 'string :type 'string
:group 'image-dired) :group 'image-dired)
(defcustom image-dired-gallery-dir (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. "Directory to store generated gallery html pages.
This path needs to be \"shared\" to the public so that it can access This path needs to be \"shared\" to the public so that it can access
the index.html page that image-dired creates." 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) :group 'image-dired)
(defcustom image-dired-temp-rotate-image-file (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." "Temporary file for rotate operations."
:type 'string :type 'string
:group 'image-dired) :group 'image-dired)

View file

@ -65,7 +65,7 @@
"Number of high scores to keep") "Number of high scores to keep")
(defvar gamegrid-user-score-file-directory (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. "A directory for game scores which can't be shared.
If Emacs was built without support for shared game scores, then this If Emacs was built without support for shared game scores, then this
directory will be used.") directory will be used.")

View file

@ -96,15 +96,7 @@ minibuffer histories, such as `compile-command' or `kill-ring'."
:group 'savehist) :group 'savehist)
(defcustom savehist-file (defcustom savehist-file
(cond (locate-user-emacs-file "history" ".emacs-history")
;; 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")))
"*File name where minibuffer history is saved to and loaded from. "*File name where minibuffer history is saved to and loaded from.
The minibuffer history is a series of Lisp expressions loaded The minibuffer history is a series of Lisp expressions loaded
automatically when `savehist-mode' is turned on. See `savehist-mode' automatically when `savehist-mode' is turned on. See `savehist-mode'

View file

@ -111,7 +111,7 @@ If set, the server accepts remote connections; otherwise it is local."
:version "22.1") :version "22.1")
(put 'server-host 'risky-local-variable t) (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." "Directory for server authentication files."
:group 'server :group 'server
:type 'directory :type 'directory

View file

@ -350,9 +350,9 @@ init file is read, in case it sets `mail-host-address'."
(defcustom auto-save-list-file-prefix (defcustom auto-save-list-file-prefix
(cond ((eq system-type 'ms-dos) (cond ((eq system-type 'ms-dos)
;; MS-DOS cannot have initial dot, and allows only 8.3 names ;; 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 (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'. "Prefix for generating `auto-save-list-file-name'.
This is used after reading your `.emacs' file to initialize This is used after reading your `.emacs' file to initialize
`auto-save-list-file-name', by appending Emacs's pid and the system name, `auto-save-list-file-name', by appending Emacs's pid and the system name,

View file

@ -2156,7 +2156,24 @@ On other systems, this variable is normally always nil.")
"~/.emacs.d/") "~/.emacs.d/")
"Directory beneath which additional per-user Emacs-specific files are placed. "Directory beneath which additional per-user Emacs-specific files are placed.
Various programs in Emacs store information in this directory. 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. ;;;; Misc. useful functions.

View file

@ -65,7 +65,7 @@
:version "22.1" :version "22.1"
:group 'multimedia) :group 'multimedia)
(defcustom thumbs-thumbsdir (concat user-emacs-directory "thumbs") (defcustom thumbs-thumbsdir (locate-user-emacs-file "thumbs")
"*Directory to store thumbnails." "*Directory to store thumbnails."
:type 'directory :type 'directory
:group 'thumbs) :group 'thumbs)

View file

@ -625,7 +625,7 @@ with some explanatory links."
(defun tutorial--saved-dir () (defun tutorial--saved-dir ()
"Directory to which tutorials are saved." "Directory to which tutorials are saved."
(expand-file-name "tutorial" user-emacs-directory)) (locate-user-emacs-file "tutorial/"))
(defun tutorial--saved-file () (defun tutorial--saved-file ()
"File name in which to save tutorials." "File name in which to save tutorials."

View file

@ -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) 2008-10-20 İsmail Dönmez <ismail@namtrac.org> (tiny change)
* url-auth.el (url-basic-auth): Encode password string. * url-auth.el (url-basic-auth): Encode password string.
@ -769,8 +773,7 @@
2005-06-14 Juanma Barranquero <lekktu@gmail.com> 2005-06-14 Juanma Barranquero <lekktu@gmail.com>
* url-history.el (url-completion-function): Follow error * url-history.el (url-completion-function): Follow error conventions.
conventions.
2005-06-13 Stefan Monnier <monnier@iro.umontreal.ca> 2005-06-13 Stefan Monnier <monnier@iro.umontreal.ca>

View file

@ -45,12 +45,8 @@
(require 'url-util) (require 'url-util)
;; FIXME convert-standard-filename?
(defcustom url-configuration-directory (defcustom url-configuration-directory
(if (and (file-directory-p user-emacs-directory) (locate-user-emacs-file ".url/" "url/")
(not (file-directory-p "~/.url")))
(expand-file-name "url" user-emacs-directory)
"~/.url")
"Directory used by the URL package for cookies, history, etc." "Directory used by the URL package for cookies, history, etc."
:type 'directory :type 'directory
:group 'url) :group 'url)