changeset 280:c738405d0d6c

mkdir -p
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 02 May 2013 11:21:30 -0700
parents 19070b2af257
children 1db0d561da2e
files .emacs
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.emacs	Wed May 01 23:01:30 2013 -0700
+++ b/.emacs	Thu May 02 11:21:30 2013 -0700
@@ -1,3 +1,4 @@
+;; emacs server (what a piece of crap)
 (require 'server)
 (or (server-running-p)
     (server-start))
@@ -9,6 +10,15 @@
 (setq truncate-partial-width-windows nil) 
 (setq use-file-dialog nil)
 
+;; make directories when they don't exist
+;; from http://stackoverflow.com/questions/6830671/how-to-make-emacs-create-intermediate-dirs-when-saving-a-file
+(add-hook 'before-save-hook
+          (lambda ()
+            (when buffer-file-name
+              (let ((dir (file-name-directory buffer-file-name)))
+                (when (not (file-exists-p dir))
+                  (make-directory dir t))))))
+
 ;; indentation
 
 ;; python indentation