Added before-save-hook to create parent directories if necessary