Here. It is nice.
My apologies for forgetting how I ended up here.
Grant, thanks for sharing this example. At the risk of asking what may be a question with a very obvious answer, have you shared your process for exporting this configuration from org-mode (init.org) to what appears to be a plain text file (init.el). I’m keen to learn how you embedded all the org headings and text into a comments region and how you managed to keep your elisp out of that region. Thanks!
This is not my example but I may be able to explain it.
In ‘init.org’, the header arguments ‘:tangle yes’ will ask org-mode create output to a file of the type specified by the source blocks, which in this file is all emacs-lisp. When ‘tangle-init’ is called, it will convert that org file into the init.el file
Grant, thanks so much for your reply! I have not used tangle but I’m guessing that ‘tangle-init’ is not customized and just comes standard with the tangle package, correct? If that’s the case, then it sounds like my next step will be to learn how to use tangle to “export” from org to elisp. This is really a great idea. I’ve made efforts to draft meaningful and concise comments in my .emacs file but it’s not as easy to browse anymore. I’m hoping this will work as a method to do the same.
‘tangle-init’ is the authors custom function in that file. ‘org-babel-tangle’ is the built in function that does the tangling. There are a lot of posts out there of different folks approaches. Mine is here https://github.com/grettke/home
I see now. I’ve never created my own function definitions in elisp so I didn’t know to look for it. But it’s there as you described.
After reviewing it, I think I probably need to go back and review the diff between init.el and .emacs. I really like the approach that both you and the author have taken in using org files to generate your configs. Thanks!
Hi, author here.
I thought I could add to Grant’s reply (to the first question). By default tangle does not include text or headings as comments. It’s the `:comments org’-part of the header-args line that enables this.
#+PROPERTY: header-args :tangle yes :comments org
Hello Lars, thanks for you reply. I really like your example. So, it sounds like `:comments org’ takes everything that’s not in between ‘#+BEGIN_SRC’ and ‘#+END_SRC’ including all the org-mode headings, subheadings, and comments and comments them out in the resulting elisp file. Thanks. Maybe using tangle is simpler than I realized.
The “meta” part of the config is all I’ve included to make sure the init-file is tangled. So I would second that it’s quite simple!
OK, I just gave this a try. But I’m not quite sure it’s working yet. So I opened up the init.org file, C-c C-v t per your instructions, and the message read:
(No changes need to be saved)
Tangled 0 code blocks from init.org
Surely I’m missing something simple. Can you advise me how to being troubleshootint?
The #+PROPERTY-line mentioned earlier needs to be loaded when it’s first added. You can do this by `C-c C-c’ when the point is at that line. It should not be necessary to do this when you open the file later.
If that’s isn’t the problem, please post your code!
Lars, here’s what I tried:
1. I saved init.org to ~/Desktop and opened it in Emacs. At the time I did so, I had already safely backed up and removed my existing .emacs and init.el files from their respective locations.
2. I opened init.org and C-c C-c on the #+PROPERTY line as you described. BTW, init.org is the same file that I downloaded from your github resource. I made no changes. After that, I got this message:
Local setup has been refreshed
SUBTREE (NO CHILDREN)
Evaluate this emacs-lisp code block on your system? (y or n) y
executing Emacs-Lisp code block…
Code block evaluation complete.
3. In init.org, I did C-c C-v t. And got this message:
Tangled 0 code blocks from init.org
I also got a symlink in the same location as init.org which had no target.
So, I think I’m one step closer to generating a init.el file from your init.org file but I’m not there yet. I didn’t post the code since it’s identical to yours but I can do so.
Thanks for your help!
I tried this three more times with the same result.
OK, I think it’s the org-version (tried tangling with `emacs -q’ and got the same result as you).
Try installing org verison 8 (or higher). BTW, if you run the init.el file (already tangled when cloned), it should install the newest version of org-mode (and lots of other packages).
Lars, I updated to org-mode 8.2.7b and then reloaded org-mode to ensure that it was running correctly.
Next I tried C-c C-c on the #+PROPERTY line. I got the following result:
org-indent-add-properties: Invalid function: org-with-silent-modifications [2 times]
Lars, I’m beginning to think that the problem is with some conflict in my older and newer org installations. I think that it’s possible I may have used two diff installation methods but I’m not sure. At any rate, I think your example is awesome and I can’t wait to try it out. But I think I’ll need to go back and clean up my org-mode install or my Emacs to get this working correctly.
Before I proceed, do you have any advice on the best method for maintaining an updated but not bleeding edge version of org? I’d prefer to just use package installation but I suppose it might make sense to build from source.
Thanks again for your help!
I use package-install. I keep all packages updated by having Emacs prompt me to update every week (part of the package section in the config), and this includes org as well.
Lars, after backing everything up, I just reinstalled Emacs, re-opened Emacs with your init.el file and let it run the updates. Magic! This is really great.
Lars, I have one more question for you. there seem to be two methods of generating init files: 1)auto-compile function which is invoked after saving a file and appears to generate an init.elc and 2) C-c C-v t which generates an init.el. Assuming I’m correct, I’m wondering if these two will conflict. Any ideas how I can avoid this?
I’m glad you like it!
Normally you’d want to tangle an org-file by using `C-c C-v t’; this should write an .el-file.
I thought it might get tedious to do this procedure each time I change my config-file, so I added a function (named `tangle-init’) that runs each time you save a file. This function tangles the source blocks into a file called `init.el’, and byte-compiles this resulting in a file called `init.elc’.
Hope this answered your question!
Lars, I’ve had some time to get this working today and it’s going very smoothly. I disabled the byte-compile option for fear that I might create a conflict between the init.el and init.elc files. What will Emacs do when it encounters two of this in the same .emacs.d directory?
Emacs always chooses .elc-files for loading, because it’s faster. So if you don’t plan on compiling, init.elc should be deleted.
I don’t run into problems with it because I always edit the init.org-file, and generate both an init.el and an init.elc. If you, however, want to edit the init.el file directly, the changes you make won’t take affect when you restart Emacs (because Emacs is actually loading the init.elc).
But remember that if you change you’re init.el directly, then you could loose these changes by tangling the init.org file.
I understand. Thanks. I’ve uncommented it in my init.org now but it doesn’t seem to compile after save. But on the bright side, your defun makes sense to me now. I’m a lisp beginner but I’m starting to get the hang of reading them.
Grant Rettke: Another #Emacs configuration in org http://t.co/6s12b2V5rL #orgmode
Notify me of followup comments via e-mail. You can also subscribe without commenting.