summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2022-08-13 18:45:19 +0200
committerThomas Letan <lthms@soap.coffee>2022-08-13 18:45:19 +0200
commit43defc95b9c0448e7e6996f6a61f549c4e3e2a24 (patch)
tree42f1dabad62f1b83583682fe1399b5a326433638
parentTypo ): (diff)
Use emacs --daemon to speed things up
-rw-r--r--.gitignore1
-rw-r--r--literate-programming.mk2
-rw-r--r--makefile20
-rw-r--r--org.mk11
-rw-r--r--scripts/cleopatra.el67
-rw-r--r--scripts/export-lp.el18
-rw-r--r--scripts/export-org.el81
-rw-r--r--scripts/init.el136
-rw-r--r--scripts/packages.el5
9 files changed, 141 insertions, 200 deletions
diff --git a/.gitignore b/.gitignore
index 816f58d..fe8d057 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@
.commands.deps
.coq.deps
.dependencies.deps
-.emacs
.emacs.d
.emacs.d/cache
.lia.cache
diff --git a/literate-programming.mk b/literate-programming.mk
index 42b1bab..e7d8cb1 100644
--- a/literate-programming.mk
+++ b/literate-programming.mk
@@ -1,6 +1,6 @@
literate-programming-prebuild : org-prebuild
@scripts/pretty-echo.sh "Tangling" "literate programming project"
- @${EMACS} --"load=scripts/export-lp.el"
+ @${EMACS} --eval "(cleopatra:export-lp)"
ARTIFACTS += lp/ site/posts/deps.svg
diff --git a/makefile b/makefile
index 8ab0819..339cc79 100644
--- a/makefile
+++ b/makefile
@@ -6,11 +6,20 @@ PROCS_DEPS := $(foreach proc,$(PROCS:.mk=.deps),.${proc})
CMD ?= postbuild
-EMACS := ROOT=$(shell pwd) emacs -Q --load="scripts/init.el" --load="scripts/packages.el" --batch
+EMACS_NAME=cleopatra
-init : ${PROCS_DEPS}
+EMACS := emacsclient -s ${EMACS_NAME}
+
+init : ${PROCS_DEPS} needs-emacs
make ${CMD}
+needs-emacs :
+ @scripts/pretty-echo.sh "Starting" "emacs daemon"
+ @${EMACS} -s ${EMACS_NAME} --eval "(kill-emacs)" || true
+ @ROOT=$(shell pwd) emacs --daemon=${EMACS_NAME} -Q --load="scripts/init.el"
+
+.PHONY : needs-emacs
+
.%.deps : %.mk makefile
@scripts/gen-deps.sh $< $@
@@ -21,11 +30,18 @@ build : prebuild
postbuild : build
postbuild :
+ @scripts/pretty-echo.sh "Updating" ".gitignore"
@scripts/update-gitignore.sh $(sort ${CONFIGURE} ${ARTIFACTS} ${PROCS_DEPS})
+ @scripts/pretty-echo.sh "Killing" "emacs daemon"
+ ${EMACS} -s ${EMACS_NAME} --eval "(kill-emacs)"
@rm -f $(wildcard .*.deps)
+.PHONY: prebuild build postbuild
+
clean :
@rm -rf ${ARTIFACTS}
cleanall : clean
@rm -rf ${CONFIGURE}
+
+.PHONY : clean cleanall
diff --git a/org.mk b/org.mk
index 2d993f1..fb2f3d4 100644
--- a/org.mk
+++ b/org.mk
@@ -1,21 +1,14 @@
ORG_IN := $(shell find site/ -name "*.org")
ORG_OUT := $(ORG_IN:.org=.html)
-org-prebuild : .emacs
org-build : ${ORG_OUT}
soupault-build : org-build
ARTIFACTS += ${ORG_OUT} .emacs.d/cache
-CONFIGURE += .emacs
-
-.emacs : scripts/packages.el
- @scripts/pretty-echo.sh echo Initiating "Emacs configuration"
- @${EMACS}
- @touch .emacs
site/index.org : site/haskell.org site/miscellaneous.org site/meta.org site/coq.org
-%.html : %.org scripts/packages.el scripts/export-org.el .emacs org.mk
+%.html : %.org org.mk
@scripts/pretty-echo.sh Exporting "$*.org"
- @${EMACS} $< --load="$(shell pwd)/scripts/export-org.el"
+ @${EMACS} --eval "(cleopatra:export-org \"$<\")"
diff --git a/scripts/cleopatra.el b/scripts/cleopatra.el
deleted file mode 100644
index 5977536..0000000
--- a/scripts/cleopatra.el
+++ /dev/null
@@ -1,67 +0,0 @@
-;;; cleopatra.el --- The cleopatra Emacs Library
-;;; Commentary:
-;;; Code:
-(require 'package)
-
-(defun cleopatra:ensure-package-installed (&rest packages)
- "Ensure every PACKAGES is installed."
- (mapcar
- (lambda (package)
- (if (package-installed-p package)
- nil
- (package-install package))
- package)
- packages))
-
-(defvar cleopatra:*emacs-dir* (concat (getenv "ROOT") "/.cleopatra/emacs.d/"))
-
-(setq user-emacs-directory cleopatra:*emacs-dir*)
-(setq package-user-dir (concat cleopatra:*emacs-dir* "packages"))
-
-(setq package-archives
- '(("gnu" . "https://elpa.gnu.org/packages/")
- ("melpa" . "https://melpa.org/packages/")
- ("org" . "https://orgmode.org/elpa/")))
-
-(package-initialize)
-
-(or (file-exists-p package-user-dir)
- (package-refresh-contents))
-
-(cleopatra:ensure-package-installed 'use-package)
-
-(require 'use-package)
-
-(use-package org :ensure org-plus-contrib :pin org)
-(use-package htmlize :ensure t)
-
-(defun cleopatra:configure ()
- (setq backup-inhibited t)
- (setq org-html-doctype "html5")
- (setq org-html-html5-fancy t)
- (setq org-src-fontify-natively t)
- (setq org-export-with-sub-superscripts nil)
- (setq org-confirm-babel-evaluate nil)
- (setq org-publish-timestamp-directory
- (concat cleopatra:*emacs-dir* "cache/"))
- (setq org-confirm-babel-evaluate nil)
- (setq org-src-preserve-indentation t)
- (add-to-list 'org-babel-default-header-args
- '(:mkdirp . "yes"))
- (add-to-list 'org-babel-default-header-args
- '(:noweb-sep . "\n\n")))
-
-(defun cleopatra:tangle-publish (conf filename _pub-dir)
- (let ((pub-dir (plist-get conf :publishing-directory)))
- (if pub-dir
- (with-temp-buffer
- (find-file-read-only filename)
- (cd (getenv "ROOT"))
- (unless (file-exists-p pub-dir)
- (make-directory pub-dir))
- (cd pub-dir)
- (org-babel-tangle))
- (error "cleopatra: missing :publishing-directory option"))))
-
-(provide 'cleopatra)
-;;; cleopatra.el ends here
diff --git a/scripts/export-lp.el b/scripts/export-lp.el
deleted file mode 100644
index bd17b0d..0000000
--- a/scripts/export-lp.el
+++ /dev/null
@@ -1,18 +0,0 @@
-;; opinionated configuration provided by cleopatra
-(cleopatra:configure)
-
-;; allow the execution of shell block code
-(org-babel-do-load-languages
- 'org-babel-load-languages
- '((shell . t)))
-
-(setq org-publish-project-alist
- '(("lp"
- :base-directory "site/posts"
- :publishing-directory "lp"
- ;; hand-pick which files to tangle (this save a lots of time)
- :exclude ".*"
- :include ("CoqffiEcho.org")
- :publishing-function cleopatra:tangle-publish)))
-
-(org-publish-all)
diff --git a/scripts/export-org.el b/scripts/export-org.el
deleted file mode 100644
index 1b20265..0000000
--- a/scripts/export-org.el
+++ /dev/null
@@ -1,81 +0,0 @@
-(cleopatra:configure)
-
-(org-babel-do-load-languages
- 'org-babel-load-languages
- '((dot . t)
- (shell . t)
- (ocaml . t)))
-
-(setq org-export-with-toc nil
- org-html-htmlize-output-type nil
- org-export-with-section-numbers nil)
-
-(add-to-list 'org-entities-user
- '("im" "\\(" nil "<span class=\"imath\">" "" "" ""))
-(add-to-list 'org-entities-user
- '("mi" "\\)" nil "</span>" "" "" ""))
-
-(defun with-keyword (keyword k)
- "Look-up for keyword KEYWORD, and call continuation K with its value."
- (pcase (org-collect-keywords `(,keyword))
- (`((,keyword . ,kw))
- (when kw (funcall k (string-join kw " "))))))
-
-(defun get-keyword (keyword)
- "Look-up for keyword KEYWORD, and returns its value"
- (with-keyword keyword (lambda (x) x)))
-
-(defun get-org-title (path)
- "Fetch the title of an Org file whose path is PATH."
- (with-temp-buffer
- (find-file-read-only path)
- (get-keyword "TITLE")))
-
-(defun insert-title ()
- "Insert the title of the article."
- (with-keyword
- "TITLE"
- (lambda (title)
- (insert
- (format "\n\n@@html:<h1>@@ %s @@html:</h1>@@\n\n" title)))))
-
-(defun insert-series ()
- "Insert the series root link."
- (with-keyword
- "SERIES"
- (lambda (series)
- (insert "\n\n#+attr_html: :class series\n")
- (insert series))))
-
-(defun insert-series-prev ()
- "Insert the series previous article link."
- (with-keyword
- "SERIES_PREV"
- (lambda (series-prev)
- (insert "\n\n#+attr_html: :class series-prev\n")
- (insert series-prev))))
-
-(defun insert-series-next ()
- "Insert the series next article link."
- (with-keyword
- "SERIES_NEXT"
- (lambda (series-next)
- (insert "\n\n#+attr_html: :class series-next\n")
- (insert series-next))))
-
-(defun insert-nav ()
- "Insert the navigation links."
- (when (get-keyword "SERIES")
- (insert "\n\n#+begin_nav\n")
- (insert-series)
- (insert-series-prev)
- (insert-series-next)
- (insert "\n\n#+end_nav\n")))
-
-(beginning-of-buffer)
-(insert-nav)
-(insert-title)
-
-(let ((outfile (org-export-output-file-name ".html"))
- (org-html-footnotes-section "<!-- %s --><!-- %s -->"))
- (org-export-to-file 'tufte-html outfile nil nil nil t))
diff --git a/scripts/init.el b/scripts/init.el
index f6f069c..0e21075 100644
--- a/scripts/init.el
+++ b/scripts/init.el
@@ -31,24 +31,115 @@
(require 'use-package)
-(use-package org :ensure org-plus-contrib)
+;; -----------------------------------------------------------------------------
+
(use-package htmlize :ensure t)
+(use-package ox-tufte :ensure t)
+(use-package tuareg :ensure t
+ :config
+ (require 'ob-ocaml))
+
+;; -----------------------------------------------------------------------------
+
+(org-babel-do-load-languages
+ 'org-babel-load-languages
+ '((dot . t)
+ (shell . t)
+ (ocaml . t)))
+
+(setq backup-inhibited t
+ org-export-with-toc nil
+ org-html-htmlize-output-type nil
+ org-export-with-section-numbers nil
+ org-html-doctype "html5"
+ org-html-html5-fancy t
+ org-src-fontify-natively t
+ org-export-with-sub-superscripts nil
+ org-confirm-babel-evaluate nil
+ org-publish-timestamp-directory (concat cleopatra:*emacs-dir* "cache/")
+ org-confirm-babel-evaluate nil
+ org-src-preserve-indentation t)
+
+(add-to-list 'org-babel-default-header-args
+ '(:mkdirp . "yes")
+(add-to-list 'org-babel-default-header-args
+ '(:noweb-sep . "\n\n")))
+
+(add-to-list 'org-entities-user
+ '("im" "\\(" nil "<span class=\"imath\">" "" "" ""))
+(add-to-list 'org-entities-user
+ '("mi" "\\)" nil "</span>" "" "" ""))
+
+(defun with-keyword (keyword k)
+ "Look-up for keyword KEYWORD, and call continuation K with its value."
+ (pcase (org-collect-keywords `(,keyword))
+ (`((,keyword . ,kw))
+ (when kw (funcall k (string-join kw " "))))))
+
+(defun get-keyword (keyword)
+ "Look-up for keyword KEYWORD, and returns its value"
+ (with-keyword keyword (lambda (x) x)))
+
+(defun get-org-title (path)
+ "Fetch the title of an Org file whose path is PATH."
+ (with-temp-buffer
+ (find-file-read-only path)
+ (get-keyword "TITLE")))
+
+(defun insert-title ()
+ "Insert the title of the article."
+ (with-keyword
+ "TITLE"
+ (lambda (title)
+ (insert
+ (format "\n\n@@html:<h1>@@ %s @@html:</h1>@@\n\n" title)))))
-(defun cleopatra:configure ()
- (setq backup-inhibited t)
- (setq org-html-doctype "html5")
- (setq org-html-html5-fancy t)
- (setq org-src-fontify-natively t)
- (setq org-export-with-sub-superscripts nil)
- (setq org-confirm-babel-evaluate nil)
- (setq org-publish-timestamp-directory
- (concat cleopatra:*emacs-dir* "cache/"))
- (setq org-confirm-babel-evaluate nil)
- (setq org-src-preserve-indentation t)
- (add-to-list 'org-babel-default-header-args
- '(:mkdirp . "yes"))
- (add-to-list 'org-babel-default-header-args
- '(:noweb-sep . "\n\n")))
+(defun insert-series ()
+ "Insert the series root link."
+ (with-keyword
+ "SERIES"
+ (lambda (series)
+ (insert "\n\n#+attr_html: :class series\n")
+ (insert series))))
+
+(defun insert-series-prev ()
+ "Insert the series previous article link."
+ (with-keyword
+ "SERIES_PREV"
+ (lambda (series-prev)
+ (insert "\n\n#+attr_html: :class series-prev\n")
+ (insert series-prev))))
+
+(defun insert-series-next ()
+ "Insert the series next article link."
+ (with-keyword
+ "SERIES_NEXT"
+ (lambda (series-next)
+ (insert "\n\n#+attr_html: :class series-next\n")
+ (insert series-next))))
+
+(defun insert-nav ()
+ "Insert the navigation links."
+ (when (get-keyword "SERIES")
+ (insert "\n\n#+begin_nav\n")
+ (insert-series)
+ (insert-series-prev)
+ (insert-series-next)
+ (insert "\n\n#+end_nav\n")))
+
+(defun cleopatra:export-org (input)
+ (with-temp-buffer
+ (insert-file-contents input)
+ (cd (file-name-directory input))
+ (beginning-of-buffer)
+ (insert-nav)
+ (insert-title)
+
+ (let ((outfile (concat (file-name-base input) ".html"))
+ (org-html-footnotes-section "<!-- %s --><!-- %s -->"))
+ (org-export-to-file 'tufte-html outfile nil nil nil t))))
+
+;; -----------------------------------------------------------------------------
(defun cleopatra:tangle-publish (conf filename _pub-dir)
(let ((pub-dir (plist-get conf :publishing-directory)))
@@ -62,5 +153,18 @@
(org-babel-tangle))
(error "cleopatra: missing :publishing-directory option"))))
+
+(defun cleopatra:export-lp ()
+ (setq-local org-publish-project-alist
+ '(("lp"
+ :base-directory "site/posts"
+ :publishing-directory "lp"
+ ;; hand-pick which files to tangle (this save a lots of time)
+ :exclude ".*"
+ :include ("CoqffiEcho.org")
+ :publishing-function cleopatra:tangle-publish)))
+
+ (org-publish-all))
+
(provide 'cleopatra)
;;; cleopatra.el ends here
diff --git a/scripts/packages.el b/scripts/packages.el
deleted file mode 100644
index 9ed944a..0000000
--- a/scripts/packages.el
+++ /dev/null
@@ -1,5 +0,0 @@
-(use-package ox-tufte :ensure t)
-
-(use-package tuareg :ensure t
- :config
- (require 'ob-ocaml))