all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Juanma Barranquero" <lekktu@gmail.com>
To: "Stefan Monnier" <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Files that begin with a period
Date: Mon, 20 Oct 2008 11:03:27 +0200	[thread overview]
Message-ID: <f7ccd24b0810200203g4f748b00w83fccfd449a95158@mail.gmail.com> (raw)
In-Reply-To: <jwvabd0mjy1.fsf-monnier+emacs@gnu.org>

On Sun, Oct 19, 2008 at 22:04, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> Nothing: I agree 100% with your change and just reminded that it would
> additionally be good to try and use user-emacs-directory (i.e. move
> those files into ~/.emacs.d).

Sixteen months ago we had a longish thread about introducing a new
function to help defaulting configuration files to .emacs.d (and
changing the name of `user-emacs-directory'):

http://lists.gnu.org/archive/html/emacs-devel/2007-06/msg00755.html

I have an old patch with the following:

--- lisp/subr.el        13 Jun 2007 00:03:28 -0000      1.555
+++ lisp/subr.el        25 Jun 2007 13:13:33 -0000
@@ -2042,5 +2042,5 @@
 (put 'cl-assertion-failed 'error-message "Assertion failed")

-(defconst user-emacs-directory
+(defconst user-data-directory
   (if (eq system-type 'ms-dos)
       ;; MS-DOS cannot have initial dot.
@@ -2049,5 +2049,21 @@
   "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-data-path'.")
+
+(defun locate-user-data-path (new-name &optional old-name)
+  "Return an absolute per-user Emacs-specific path.
+If OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
+Else return NEW-NAME in `user-data-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-data-directory)))
+        (make-directory user-data-directory t))  ;; don't catch errors
+      (expand-file-name new-name user-data-directory)))))

The idea was to help converting something like this:

(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")))
  ...)

into

(defcustom savehist-file
  (locate-user-data-path "history" ".emacs-history")
  ...)

In the thread there was much discussion about names, and I haven't
tried to maintain the patch up-to-date. I still think a function like
this one would be helpful, though.

  Juanma




  reply	other threads:[~2008-10-20  9:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-19 10:29 Files that begin with a period Eli Zaretskii
2008-10-19 13:07 ` Stefan Monnier
2008-10-19 13:39   ` Eli Zaretskii
2008-10-19 20:04     ` Stefan Monnier
2008-10-20  9:03       ` Juanma Barranquero [this message]
2008-10-20 11:19         ` Eli Zaretskii
2008-10-20 11:32           ` Juanma Barranquero
2008-10-20 12:07             ` Eli Zaretskii
2008-10-23 18:29             ` Stefan Monnier
2008-10-23 21:49               ` Eli Zaretskii
2008-10-24  9:46                 ` Juanma Barranquero
2008-10-24  4:18               ` Stephen J. Turnbull
2008-10-24 10:25               ` Juanma Barranquero
2008-10-20  9:33       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ccd24b0810200203g4f748b00w83fccfd449a95158@mail.gmail.com \
    --to=lekktu@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.