From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.devel Subject: Re: Don't concat directories to file names Date: Fri, 15 Jun 2007 13:21:37 +0200 Message-ID: References: <87wsy6cvip.fsf@uwakimon.sk.tsukuba.ac.jp> <87k5u5cydi.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1181906541 16234 80.91.229.12 (15 Jun 2007 11:22:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2007 11:22:21 +0000 (UTC) Cc: rms@gnu.org, emacs-devel@gnu.org To: "Stephen J. Turnbull" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 15 13:22:19 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hz9sg-0004NG-UD for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2007 13:22:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hz9sg-00064g-3B for ged-emacs-devel@m.gmane.org; Fri, 15 Jun 2007 07:22:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hz9s4-0005lg-0G for emacs-devel@gnu.org; Fri, 15 Jun 2007 07:21:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hz9s3-0005l4-41 for emacs-devel@gnu.org; Fri, 15 Jun 2007 07:21:39 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hz9s2-0005l0-Vh for emacs-devel@gnu.org; Fri, 15 Jun 2007 07:21:39 -0400 Original-Received: from wx-out-0506.google.com ([66.249.82.235]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hz9s2-0005kW-L0 for emacs-devel@gnu.org; Fri, 15 Jun 2007 07:21:38 -0400 Original-Received: by wx-out-0506.google.com with SMTP id h26so986679wxd for ; Fri, 15 Jun 2007 04:21:38 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LP8EjNm0IGj7jzpl3RZ1WVhu+UhGmiZApZslvYGV2otFSFSqTLPuR2OlhVL4NOmYc1TchyKnKdi5rlIFMoivU037Di1JTdFFDaPO2iSUcbErXUrv6GqfPSNoF7W8/Ep0aCCdnFyujWtYZT+HkBV08BfP2pCqLdnOz0Xrk1T89h4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bToXig21VOKZB6guiEul2ZGb+Wcpj1u7CwSyLJJ+YX/HrYTpXeC8hL+jay8lJpw3k9xC5ss90N/2KdDjjUCls9hdWqqq+ZUkLBZwdnUT2Td7MUhIXyvCZMIu2HqHzaEgLIiZvf04bWM9M0bVigO+brMdxrsKAPnU7BKuK7NU1BM= Original-Received: by 10.90.25.3 with SMTP id 3mr2343032agy.1181906497918; Fri, 15 Jun 2007 04:21:37 -0700 (PDT) Original-Received: by 10.90.87.8 with HTTP; Fri, 15 Jun 2007 04:21:37 -0700 (PDT) In-Reply-To: <87k5u5cydi.fsf@uwakimon.sk.tsukuba.ac.jp> Content-Disposition: inline X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:72945 Archived-At: On 6/15/07, Stephen J. Turnbull wrote: > XEmacs doesn't enforce it (we can't without imposing a gratuitous > incompatibility, since until now Emacs hasn't really had the concept), Aha. > but the variable `user-init-directory' is available to any library > that wants an Emacs-specific place to put things. This is normally > initialized to "~/.xemacs" by startup.el. Then the recently introduced `user-emacs-directory' should be renamed to `user-init-directory', or aliased, I think (but it doesn't make much sense to alias a just created var). The variable currently must end with a directory separator, but that could be fixed. But all in all, what I'm interested is having a public function so modules that currently do (defvar my-module-setup-file "~/.my-module-data") or (defvar my-module-setup-file (cond ((file-exists-p "~/.my-module-data") "~/.my-module-data") ((file-directory-p "~/.emacs.d/" "~/.emacs.d/my-module-setup")) (t ...))) can be easily transformed to (defvar my-module-setup-file (user-emacs-file "my-module-data" ; back-compatible "my-module-setup" ; optional, default to above )) i.e. (it's a reworked version): (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' is nil, 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 (concat "~" init-file-user)))) (if (or (file-readable-p at-home) (null user-emacs-directory)) at-home (or (file-accessible-directory-p (directory-file-name user-emacs-directory)) (progn (make-directory user-emacs-directory) t) ;; don't catch errors (expand-file-name (or new-name name) user-emacs-directory)))))) That function makes use of `user-emacs-directory' (that'd be `user-init-directory', in XEmacs); uses `convert-standard-filename' and, as requested, creates the ~/.emacs.d (~/.xemacs) directory on the fly. People wanting to use the same setup files in X?Emacs will have to make user-(emacs|init)-directory point to the right place, or perhaps set it to nil (and then `user-emacs-file' defers to ~/ and does not try to create any dir). WDYT? Juanma