holomorph / systemd-mode

Major mode for editing systemd units
GNU General Public License v3.0
54 stars 20 forks source link

Fix txt file paths during native-compile-async #18

Open pdbrown opened 2 years ago

pdbrown commented 2 years ago

Hey there, thanks for putting this mode up! I've been using it with native compilation recently, and noticed errors about missing files that only occur when native-compiling in async mode. This PR fixes up path name resolution for the defconst expressions.


When building systemd.el with async native compile, we can't rely on load-file-name, so fall back to the native relative path lookup performed in insert-file-contents.

native-compile-async runs compilation in a subprocess launched by loading an elisp program from a temporary file:

(native-compile-async "/home/phil/.emacs.d/systemd/systemd.el") => invokes emacs --batch -l /tmp/emacs-async-comp-systemd-BZ3kNs.el

Inside the subprocess, load-file-name is /tmp/emacs-async-comp-systemd-BZ3kNs.el instead of .../systemd/systemd.el and the local txt resource files (unit-directives.txt etc) aren't resolvable from /tmp.