summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-11-06 00:52:00 +0100
committerGravatar Tom Willemsen2012-11-06 00:52:00 +0100
commit40c78e93c95543042f8ff8d8fd0337f8403bebd5 (patch)
tree16b4603933bb90dac5b6c46fa48431d0e9863d79
parent7e13a5b9b5d596d078c8d45eece090d1a1b8145b (diff)
downloadsite-40c78e93c95543042f8ff8d8fd0337f8403bebd5.tar.gz
site-40c78e93c95543042f8ff8d8fd0337f8403bebd5.zip
Add "eval-and-compile" archive post
-rw-r--r--posts/eval-and-compile.mdwn53
1 files changed, 53 insertions, 0 deletions
diff --git a/posts/eval-and-compile.mdwn b/posts/eval-and-compile.mdwn
new file mode 100644
index 0000000..6975120
--- /dev/null
+++ b/posts/eval-and-compile.mdwn
@@ -0,0 +1,53 @@
+I'm reading up a little on byte-compilation in
+[GNU Emacs](http://www.gnu.org/software/emacs/) and I read about just
+exactly a feature that I needed.
+
+A while ago, I was working on my init<sup><a class="footref"
+name="fnr.1" href="#fn.1">1</a></sup> file, adding some
+`auto-complete` code since I wanted to try it again. I
+noticed that, because `auto-complete` is installed through
+`package`, it couldn't load the appropriate files at
+compile time.
+
+I know that `package-initialize` should be called before calling or
+using any `package`-installed functions and I have it in my
+init<sup><a class="footref" name="fnr.1.2" href="#fn.1">1</a></sup>
+file, but this doesn't help at compile time. So, ugly as I thought it
+was, I added
+
+[[!format el """
+(eval-when-compile (package-initialize))
+"""]]
+
+just above the call to the `auto-complete` functions. I hated having
+to do that, I know it's just one line, but its not at all DRY<sup><a
+class="footref" name="fnr.2" href="#fn.2">2</a></sup>.
+
+Just now, though, I read about `eval-and-compile`, and according to
+the documentation in the elisp reference manual, it should do exactly
+what I want, eval both when running and when compiling.
+
+[[!format el """
+(eval-and-compile (package-initialize))
+"""]]
+
+I'm currently trying it out, I just tested it once and it seems to
+work like a charm.
+
+*Of course*, this might never have been an issue if I didn't use
+`emacs -Q` to compile my init<sup><a class="footref" name="fnr.1.3"
+href="#fn.1">1</a></sup> file, just to speed up loading during
+compilation a little bit.
+
+<div id="footnotes">
+<h3 class="footnotes">Footnotes: </h3>
+<div id="text-footnotes">
+<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a></sup> <a href="http://ryuslash.org/dotfiles/emacs/init.html">http://ryuslash.org/dotfiles/emacs/init.html</a>
+</p>
+<p class="footnote"><sup><a class="footnum" name="fn.2" href="#fnr.2">2</a></sup> Don't Repeat Yourself
+</p>
+</div>
+</div>
+
+[[!meta date="2012-07-27 21:19:00"]]
+[[!tag emacs elisp dotfiles coding]]