From 8db4f9eedd2a1e638b34789c2aa4d5c33711238f Mon Sep 17 00:00:00 2001 From: MitchMarq42 Date: Thu, 4 May 2023 21:06:18 -0800 Subject: [PATCH] re-enable ox-hugo --- lisp/mitch-packages.el | 68 +++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/lisp/mitch-packages.el b/lisp/mitch-packages.el index d29313f..89ff6c2 100644 --- a/lisp/mitch-packages.el +++ b/lisp/mitch-packages.el @@ -625,40 +625,40 @@ targets." :states 'normal :keymaps 'org-src-mode-map "ZZ" 'org-edit-src-exit)) -;; (use-package ox-hugo -;; :after org -;; :config -;; (defun hugo-dir-above (dir) -;; "Return path of Hugo project root above or at DIR. -;; Return nil if DIR is not in a hugo project at all." -;; (let ((thisdir dir)) -;; (let ((lexical-binding t)) -;; (if (eq thisdir nil) nil -;; (if (file-exists-p (expand-file-name "config.toml" thisdir)) -;; thisdir -;; (let ((updir (file-name-directory (string-trim-right thisdir "/")))) -;; (hugo-dir-above updir))))))) -;; ;; (hugo-dir-above "~/.local/git/mitchmarq42.github.io/content-org/") -;; (defun hugo-compile (&optional dir) -;; (interactive) -;; (if (bound-and-true-p dir) nil -;; (setq dir default-directory)) -;; (let ((hugo-dir (hugo-dir-above dir))) -;; (if hugo-dir -;; (progn -;; (if (string-match-p (rx bol (* any) "/content-org" (opt "/") eol) -;; default-directory) -;; (org-hugo-export-wim-to-md)) -;; (let* ((default-directory hugo-dir) -;; (buffer (get-buffer-create "*hugo*"))) -;; (with-current-buffer buffer -;; ;; (compilation-mode) -;; (let* ((inhibit-read-only t) -;; (status-code (call-process-shell-command "hugo" nil buffer))) -;; (if (zerop status-code) -;; (message "Hugo re-generated!") -;; (error "Hugo exited %s, better change something!" status-code))))))))) -;; (add-hook 'after-save-hook #'hugo-compile)) +(use-package ox-hugo + :after org + :config + (defun hugo-dir-above (dir) + "Return path of Hugo project root above or at DIR. +Return nil if DIR is not in a hugo project at all." + (let ((thisdir dir)) + (let ((lexical-binding t)) + (if (eq thisdir nil) nil + (if (file-exists-p (expand-file-name "config.toml" thisdir)) + thisdir + (let ((updir (file-name-directory (string-trim-right thisdir "/")))) + (hugo-dir-above updir))))))) + ;; (hugo-dir-above "~/.local/git/mitchmarq42.github.io/content-org/") + (defun hugo-compile (&optional dir) + (interactive) + (if (bound-and-true-p dir) nil + (setq dir default-directory)) + (let ((hugo-dir (hugo-dir-above dir))) + (if hugo-dir + (progn + (if (string-match-p (rx bol (* any) "/content-org" (opt "/") eol) + default-directory) + (org-hugo-export-wim-to-md)) + (let* ((default-directory hugo-dir) + (buffer (get-buffer-create "*hugo*"))) + (with-current-buffer buffer + ;; (compilation-mode) + (let* ((inhibit-read-only t) + (status-code (call-process-shell-command "hugo" nil buffer))) + (if (zerop status-code) + (message "Hugo re-generated!") + (error "Hugo exited %s, better change something!" status-code))))))))) + (add-hook 'after-save-hook #'hugo-compile)) (use-package ox-clip :commands ox-clip-formatted-copy)