changeset 4382:12ff8dc2b57e

Create the containing directory for the custom and init files if necessary. 2008-01-03 Aidan Kehoe <kehoea@parhasard.net> * cus-edit.el (custom-save-all): If the directory containing the custom file doesn't exist, try to create it. Fixes Nick's Crabtree's bug of 5fb265820712140145w512fa3bbh355cf76f7e2cf792@mail.gmail.com ; thank you Nick. * menubar-items.el (default-menubar): In the code to edit the user's init file, try to create the containing directory if it doesn't exist.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 03 Jan 2008 12:45:44 +0100
parents 3906442b491b
children 1e04b9c8125b
files lisp/ChangeLog lisp/cus-edit.el lisp/menubar-items.el
diffstat 3 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Jan 03 01:33:59 2008 -0800
+++ b/lisp/ChangeLog	Thu Jan 03 12:45:44 2008 +0100
@@ -1,3 +1,14 @@
+2008-01-03  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* cus-edit.el (custom-save-all): 
+	If the directory containing the custom file doesn't exist, try to
+	create it. Fixes Nick's Crabtree's bug of 
+	5fb265820712140145w512fa3bbh355cf76f7e2cf792@mail.gmail.com ;
+	thank you Nick.
+	* menubar-items.el (default-menubar):
+	In the code to edit the user's init file, try to create the
+	containing directory if it doesn't exist. 
+
 2008-01-02  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* gtk-init.el (init-post-gtk-win): 
--- a/lisp/cus-edit.el	Thu Jan 03 01:33:59 2008 -0800
+++ b/lisp/cus-edit.el	Thu Jan 03 12:45:44 2008 +0100
@@ -3766,7 +3766,13 @@
     (custom-save-variables)
     (custom-save-faces)
     (let ((find-file-hooks nil)
-	  (auto-mode-alist))
+	  (auto-mode-alist)
+          custom-file-directory)
+      (unless (file-directory-p (setq custom-file-directory 
+                                      (file-name-directory custom-file)))
+        (message "Creating %s... " custom-file-directory)
+        (make-directory custom-file-directory t)
+        (message "Creating %s... done." custom-file-directory))
       (with-current-buffer (find-file-noselect custom-file)
 	(save-buffer)))))
 
--- a/lisp/menubar-items.el	Thu Jan 03 01:33:59 2008 -0800
+++ b/lisp/menubar-items.el	Thu Jan 03 12:45:44 2008 +0100
@@ -1441,10 +1441,16 @@
      ["Edit I%_nit File"
       ;; #### there should be something that holds the name that the init
       ;; file should be created as, when it's not present.
-      (let ((el-file (or user-init-file "~/.xemacs/init.el")))
+      (let ((el-file (or user-init-file "~/.xemacs/init.el"))
+            el-file-directory)
 	(if (string-match "\\.elc$" el-file)
 	    (setq el-file
 		  (substring user-init-file 0 (1- (length el-file)))))
+        (unless (file-directory-p
+                 (setq el-file-directory (file-name-directory el-file)))
+          (message "Creating %s... " el-file-directory)
+          (make-directory el-file-directory t)
+          (message "Creating %s... done." el-file-directory))
 	(find-file el-file)
 	(or (eq major-mode 'emacs-lisp-mode)
 	    (emacs-lisp-mode)))]