Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options to set or prompt for directory to save export to #3

Open
mooseyboots opened this issue Mar 27, 2022 · 0 comments
Open

options to set or prompt for directory to save export to #3

mooseyboots opened this issue Mar 27, 2022 · 0 comments

Comments

@mooseyboots
Copy link

i keep my text files outside my blog, so i want to save my .md exports to a different location, and i don't always publish them in the same directory on my site.

i came up with this:

(defcustom org-export-jekyll-md-project-directory default-directory
  "Directory to save exported articles to.
\nDefaults to `default-directory' (i.e. current directory). See
`org-export-jekyll-md-use-project-directory-and-prompt' if you
want to choose a directory on saving."
  :group 'org-export-jekyll
  :type 'string)

(defcustom org-export-jekyll-md-prompt-for-directory nil
  "Non-nil means prompt for a directory to save in.
\nStart at `org-export-jekyll-md-project-directory'. Nil means
use `org-export-jekyll-md-project-directory' with no prompt."
  :group 'org-export-jekyll
  :type 'boolean)

(defun org-jekyll-md-export-to-md (&optional async subtreep visible-only)
  "Export current buffer to a Markdown file adding some YAML front matter.
\nThe file is saved to `org-export-jekyll-md-project-directory'.
If `org-export-jekyll-md-prompt-for-directory' is non-nil, prompt
for a directory to save to."
  (interactive)
  (let* ((pub-dir (if org-export-jekyll-md-prompt-for-directory
                    (read-directory-name "Save to: "
                                         org-export-jekyll-md-project-directory
                                         nil
                                         t)
                    org-export-jekyll-md-project-directory))
         (outfile (concat pub-dir
                          (org-jekyll-md-filename-date)
                          (org-export-output-file-name ".md" subtreep))))
    (org-export-to-file 'jekyll outfile async subtreep visible-only)))

first option: set a different destination directory, second option: prompt each time for a directory to save in. either or both can be set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant