When I decided to share my limited wisdom, I realized I’d
need something better than a 4-year-old, thrown together,
init file. The words “init dot org” had crossed my ears
through one of Sacha Chua’s previous videos; however, due to
63m of water above my head, internet searches weren’t quite
operating at top efficiency.
Without a second thought, and armed with nothing but its
name (init.org), I took to writing —I thought at the
moment— the simplest way of implementing such a feature.
;;; init.el(defvarendless/init.org-message-depth3"What depth of init.org headers to message at startup.")(with-temp-buffer(insert-file"~/.emacs.d/init.org")(goto-char(point-min))(search-forward"\n* init.el")(while(not(eobp))(forward-line1)(cond;; Report Headers((looking-at(format"\\*\\{2,%s\\} +.*$"endless/init.org-message-depth))(message"%s"(match-string0)));; Evaluate Code Blocks((looking-at"^#\\+BEGIN_SRC +emacs-lisp *$")(let((l(match-end0)))(search-forward"\n#+END_SRC")(eval-regionl(match-beginning0))));; Finish on the next level-1 header((looking-at"^\\* ")(goto-char(point-max))))))
Once back within the range of cell towers, a quick search
revealed it could have been slightly shorter.
Nonetheless, I stuck with my guns and kept the first version.
Primarily for stubbornness, but also a few other reasons:
Fine grained control
I can choose exactly what gets
evaluated. In this case, anything inside the
init.el header. This is important because this blog
is my init file, and I don’t want to evaluate everything
I post.
Lots of messaging
It calls message on each header it
finds (up to a configurable level). Whenever something goes
wrong, forget about restarting with --debug-init, the
messages buffer tells me exactly where it happened.
It doesn’t (require 'org)
This might sound silly, but
that inconspicuous line forms one of the most
time-consuming statements you could possibly write. I’d
challenge anyone to find a 14-character statement that
takes longer than that (other than an empty loop or a
sleep command, of course).
init.org Without org-mode
26 Jun 2014, by Artur Malabarba.About the Blog post series
When I decided to share my limited wisdom, I realized I’d need something better than a 4-year-old, thrown together, init file. The words “init dot org” had crossed my ears through one of Sacha Chua’s previous videos; however, due to 63m of water above my head, internet searches weren’t quite operating at top efficiency.
Without a second thought, and armed with nothing but its name (init.org), I took to writing —I thought at the moment— the simplest way of implementing such a feature.
Once back within the range of cell towers, a quick search revealed it could have been slightly shorter.
Nonetheless, I stuck with my guns and kept the first version. Primarily for stubbornness, but also a few other reasons:
init.el
header. This is important because this blog is my init file, and I don’t want to evaluate everything I post.message
on each header it finds (up to a configurable level). Whenever something goes wrong, forget about restarting with--debug-init
, the messages buffer tells me exactly where it happened.(require 'org)
Tags: init.el, org-mode, blog, emacs,
Checkdoc, Package Developing, and Cakes »
Related Posts
Define context-aware keys in Emacs in org-mode
Changing the org-mode ellipsis in org-mode
Better time-stamps in org-export in org-mode
Content © 2019, All rights reserved. Icons under CC3.0.