From ebb8631a8135114c3bd9262604532672acba90ed Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sat, 1 Jan 2022 13:12:50 +0100 Subject: [PATCH] If README.org file write README.md on save custom function --- bundle/bundle--org.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bundle/bundle--org.el b/bundle/bundle--org.el index 3e517517..baa95a2f 100644 --- a/bundle/bundle--org.el +++ b/bundle/bundle--org.el @@ -113,7 +113,15 @@ (shell . t) (plantuml . t) (typescript . t) - (http . t)))) + (http . t))) + (defun me/write-readme-md-on-save () + ;; when README.org, also write README.md on save + (when (string-match "README" (buffer-file-name)) + (make-local-variable 'after-save-hook) + (add-hook 'after-save-hook + (lambda () (let ((outfile (org-export-output-file-name ".md"))) + (org-export-to-file 'md outfile)))))) + (add-hook 'org-mode-hook 'me/write-readme-md-on-save)) (use-package org-roam :init