Created Use org-roam V2 "--with-native-compilation" (markdown)

Philippe Crama
2021-11-10 19:00:13 +01:00
parent ae58cb295f
commit 06e4963fff

@@ -0,0 +1,22 @@
Even after setting `org-roam-v2-ack` to `t` in my `init.el` file, everytime my Emacs updated org-roam (through M-x `list-packages`) native compilation would display the "You are now on V2" warning and native compilation would fail.
The problem is that the package was compiled to native code asynchronously (i.e. with a separate emacs process started with `--batch` that did not read my `init.el` file) `org-roam-v2-ack` was not set; resulting in the warning (with `:error` level) that aborted the native compilation. Luckily, there is the `native-comp-async-env-modifier-form` that can be customized to add some code to execute before compiling asynchronously, so I solved it like this:
(defun phc-prognify-and-append (form new-form)
"Wrap FORM in `progn' if needed and append NEW-FORM"
(cond ((and (consp form)
(eq (car form) 'progn))
(append form (list new-form)))
((null form)
`(progn ,new-form))
(t
`(progn ,form ,new-form))))
(use-package org-roam
;; ... snip other configuration irrelevant for this wiki page ...
:init
(defvar org-roam-v2-ack t)
(set-default 'native-comp-async-env-modifier-form
(phc-prognify-and-append
(when (boundp 'native-comp-async-env-modifier-form)
native-comp-async-env-modifier-form)
`(defvar org-roam-v2-ack ,org-roam-v2-ack))))