]> git.eshelyaron.com Git - esy-publish.git/commitdiff
Kill buffers opened during export
authorEshel Yaron <me@eshelyaron.com>
Sun, 16 Apr 2023 16:12:10 +0000 (19:12 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sun, 16 Apr 2023 16:12:10 +0000 (19:12 +0300)
esy-publish.el

index 57dda0105d9e4604595d89be5482826389d57933..ead4a2dee07fa2c07738636bf46e3edccccf2264 100644 (file)
@@ -6,7 +6,7 @@
 ;; Maintainer: Eshel Yaron <me@eshelyaron.com>
 ;; Keywords: languages extensions
 ;; URL: http://git.eshelyaron.com/gitweb/?p=esy-publish.git
-;; Package-Version: 0.6.0
+;; Package-Version: 0.7.0
 ;; Package-Requires: ((emacs "28.2"))
 
 ;; This file is NOT part of GNU Emacs.
   (with-current-buffer
       (find-file-noselect
        (expand-file-name "esy.org" esy-publish-source-directory))
-    (org-transclusion-add-all)))
+    (org-transclusion-add-all)
+    (push (current-buffer) esy-publish--buffers)))
 
 (defun esy-publish--prepare-indices (&rest _)
   (dolist (dir (list esy-publish-notes-source-directory
                      esy-publish-posts-source-directory
                      esy-publish-source-directory))
     (with-current-buffer (find-file-noselect (expand-file-name "index.org" dir))
-      (org-update-all-dblocks))))
+      (org-update-all-dblocks)
+      (push (current-buffer) esy-publish--buffers))))
 
 (defun esy-publish--prepare-notes-links (&rest _)
   (dolist (note (delete "index.org"
                                          (rx bos alnum (+ any)
                                              ".org" eos))))
     (with-current-buffer (find-file-noselect note)
-      (org-update-all-dblocks))))
+      (org-update-all-dblocks)
+      (push (current-buffer) esy-publish--buffers))))
 
 (defun esy-publish--prepare (&rest _)
   (esy-publish--transclude-config)
         (replace-match (format "<link rel=\"canonical\" href=\"%s\" />"
                                (esy-publish--file-url file))
                        nil t))
-      (basic-save-buffer))))
+      (basic-save-buffer)
+      (push (current-buffer) esy-publish--buffers))))
 
 (defun esy-publish--finalize (plist)
   (esy-publish--add-canonical-tags plist)
   (esy-publish--finalize-feed plist)
   (esy-publish--finalize-sitemap plist))
 
+(defvar esy-publish--buffers nil)
+
 ;;;###autoload
 (defun esy-publish (&optional force)
   (interactive "P")
          (org-src-lang-modes nil)
          (prog-mode-hook '(rainbow-delimiters-mode))
          (make-backup-files nil)
+         (auto-save-default nil)
+         (esy-publish--buffers nil)
          (org-publish-project-alist
           (list '("all" :components ("assets" "org"))
                 (list "assets"
                                   "© "
                                   (time ((class . "copyright-year")) "2023")
                                   " %a"))))))))
-    (org-publish "all" force)))
+    (org-publish "all" force)
+    (dolist (buffer esy-publish--buffers)
+      (kill-buffer)))
+  (setq esy-publish--buffers nil))
 
 (defun esy-publish-all ()
   (esy-publish t))