Hugo recompile on save
This commit is contained in:
parent
3c91283f03
commit
102c4d447f
@ -657,11 +657,19 @@ Return nil if DIR is not in a hugo project at all."
|
|||||||
(if (eq dir nil) nil
|
(if (eq dir nil) nil
|
||||||
(if (file-exists-p (expand-file-name "config.toml" dir)) dir
|
(if (file-exists-p (expand-file-name "config.toml" dir)) dir
|
||||||
(hugo-dir-above (file-name-directory (string-trim-right dir "/"))))))
|
(hugo-dir-above (file-name-directory (string-trim-right dir "/"))))))
|
||||||
(add-hook 'after-save-hook
|
(defun hugo-compile (dir)
|
||||||
(lambda () (let ((hugo-dir (hugo-dir-above default-directory)))
|
(let ((hugo-dir (hugo-dir-above dir)))
|
||||||
(if hugo-dir
|
(if hugo-dir
|
||||||
(let ((default-directory hugo-dir))
|
(let* ((default-directory hugo-dir)
|
||||||
(shell-command "hugo")))))))
|
(buffer (get-buffer-create "*hugo*")))
|
||||||
|
(pop-to-buffer buffer)
|
||||||
|
(compilation-mode)
|
||||||
|
(if (zerop (let ((inhibit-read-only t))
|
||||||
|
(call-process "sh" nil buffer t "-c" "hugo")))
|
||||||
|
(message "Hugo re-generated!")
|
||||||
|
(error "Hugo Failed, better change something!"))))))
|
||||||
|
(add-hook 'after-save-hook
|
||||||
|
(lambda () (hugo-compile default-directory))))
|
||||||
|
|
||||||
;; fake indentation, other than the other fake indentation
|
;; fake indentation, other than the other fake indentation
|
||||||
(use-package adaptive-wrap
|
(use-package adaptive-wrap
|
||||||
|
Loading…
Reference in New Issue
Block a user