From 06e4963fffce9a9c5f2f3c28557eb552d71267cd Mon Sep 17 00:00:00 2001 From: Philippe Crama Date: Wed, 10 Nov 2021 19:00:13 +0100 Subject: [PATCH] Created Use org-roam V2 "--with-native-compilation" (markdown) --- ...-roam-V2-\"--with-native-compilation\".md" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "Use-org-roam-V2-\"--with-native-compilation\".md" diff --git "a/Use-org-roam-V2-\"--with-native-compilation\".md" "b/Use-org-roam-V2-\"--with-native-compilation\".md" new file mode 100644 index 0000000..2429ef6 --- /dev/null +++ "b/Use-org-roam-V2-\"--with-native-compilation\".md" @@ -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))))