[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Don't concat directories to file names

From: Juanma Barranquero
Subject: Re: Don't concat directories to file names
Date: Thu, 14 Jun 2007 17:16:39 +0200

On 6/13/07, Richard Stallman <address@hidden> wrote:

    -(defcustom image-dired-dir "~/.emacs.d/image-dired/"
    +(defcustom image-dired-dir (concat user-emacs-directory "image-dired/")

This has the right result, but for clarity such code really ought to
use expand-file-name.

I think we should add a function like the one below (with a better
name and docstring, of course), so we can "move" all these
configuration files and directories which are not yet in ~/.emacs.d/,
for example .calc.el, .abbrev_defs, .bdf-cache.el, .emacs-places,
.strokes, .type-break, .timelog, .vip, .viper, .eshell, .quickurls,
.emacs_case_exceptions, .idlwave, .ido-last, .recentf, .emacs_args,
.shadows, .wmncach.el, diary, .eshell/, etc. etc.

The NEW-NAME arg in the function is to allow things like .emacs vs.
init.el, or .completions vs. completions.



Index: lisp/subr.el
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.555
diff -u -2 -r1.555 subr.el
--- lisp/subr.el        13 Jun 2007 00:03:28 -0000      1.555
+++ lisp/subr.el        14 Jun 2007 14:13:59 -0000
@@ -2051,4 +2051,19 @@
Note that this should end with a directory separator.")

+(defun user-emacs-file (name &optional new-name)
+  "Convert NAME to an absolute per-user Emacs-specific path.
+If \"~/NAME\" exists, or `user-emacs-directory' does not, return \"~/NAME\".
+Else, return \"`user-emacs-directory'/NEW-NAME\", or /NAME if NEW-NAME is nil."
+  (convert-standard-filename
+   (let ((at-home (expand-file-name name "~")))
+     (cond
+       ;; Backwards compatibility
+       ((file-readable-p at-home) at-home)
+       ;; Preferred for new installations
+       ((file-directory-p user-emacs-directory)
+       (expand-file-name (or new-name name) user-emacs-directory))
+       ;; If ~/.emacs.d/ does not exist
+       (t at-home)))))
;;;; Misc. useful functions.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]