Skip to main content
Added text about evaluating code directly in the config file.
Source Link

If you're attempting your first config, I would suggest keeping it simple and just using org-babel-load-file:

I would suggest renaming the org file to something like config.org and have an init.el that contains only

;; init.el (org-babel-load-file (concat user-emacs-directory "config.org")) 

This creates a file config.el by tangling config.org and loads it. My real config is in config.org. I chose that name simply because it avoids confusion between the init.el that you wrote and the one generated by tangling init.org.

You can version-control config.org and put config.el in your gitignore.

In your config.org (or any other name that isn't init.org) you can also put this

(setq custom-file (concat user-emacs-directory "custom-file.el")) (unless (file-exists-p custom-file) (write-region "" nil custom-file)) (load custom-file) 

and gitignore custom-file.el (or your choice of filename).

If you do that, emacs will not change your init.el meaning that you can version control it too and you don't have to do git update-index --assume-unchanged init.el which has drawbacks.

This is missing her tangle-init that runs automatically tangles the file when you save it but it's going to get tangled anyway when you startup Emacs.

Also I'm guessing the tangle-init that runs every time you save is meant to save time when you're working on your config but Emacs is a running interpreter. In your org file, you can do C-c C-c on an SRC block to evaluate just that block, and you can do C-x C-e to evaluate the s-exp before your cursor (your cursor after the closing parenthesis or on it if you are using evil mode).

I usually apply changes to my configuration that way and before I make a commit, I might do a restart of Emacs just to make sure or if it makes sense intuitively (like if you delete a line that does (setq x y) from an SRC block and you evaluate that block with C-c C-c, x doesn't go away. But if you change it to (setq x z) you can just C-x C-e that expression without needing to restart.

If you're attempting your first config, I would suggest keeping it simple and just using org-babel-load-file:

I would suggest renaming the org file to something like config.org and have an init.el that contains only

;; init.el (org-babel-load-file (concat user-emacs-directory "config.org")) 

This creates a file config.el by tangling config.org and loads it. My real config is in config.org. I chose that name simply because it avoids confusion between the init.el that you wrote and the one generated by tangling init.org.

You can version-control config.org and put config.el in your gitignore.

In your config.org (or any other name that isn't init.org) you can also put this

(setq custom-file (concat user-emacs-directory "custom-file.el")) (unless (file-exists-p custom-file) (write-region "" nil custom-file)) (load custom-file) 

and gitignore custom-file.el (or your choice of filename).

If you do that, emacs will not change your init.el meaning that you can version control it too and you don't have to do git update-index --assume-unchanged init.el which has drawbacks.

This is missing her tangle-init that runs automatically tangles the file when you save it but it's going to get tangled anyway when you startup Emacs.

If you're attempting your first config, I would suggest keeping it simple and just using org-babel-load-file:

I would suggest renaming the org file to something like config.org and have an init.el that contains only

;; init.el (org-babel-load-file (concat user-emacs-directory "config.org")) 

This creates a file config.el by tangling config.org and loads it. My real config is in config.org. I chose that name simply because it avoids confusion between the init.el that you wrote and the one generated by tangling init.org.

You can version-control config.org and put config.el in your gitignore.

In your config.org (or any other name that isn't init.org) you can also put this

(setq custom-file (concat user-emacs-directory "custom-file.el")) (unless (file-exists-p custom-file) (write-region "" nil custom-file)) (load custom-file) 

and gitignore custom-file.el (or your choice of filename).

If you do that, emacs will not change your init.el meaning that you can version control it too and you don't have to do git update-index --assume-unchanged init.el which has drawbacks.

This is missing her tangle-init that runs automatically tangles the file when you save it but it's going to get tangled anyway when you startup Emacs.

Also I'm guessing the tangle-init that runs every time you save is meant to save time when you're working on your config but Emacs is a running interpreter. In your org file, you can do C-c C-c on an SRC block to evaluate just that block, and you can do C-x C-e to evaluate the s-exp before your cursor (your cursor after the closing parenthesis or on it if you are using evil mode).

I usually apply changes to my configuration that way and before I make a commit, I might do a restart of Emacs just to make sure or if it makes sense intuitively (like if you delete a line that does (setq x y) from an SRC block and you evaluate that block with C-c C-c, x doesn't go away. But if you change it to (setq x z) you can just C-x C-e that expression without needing to restart.

Source Link

If you're attempting your first config, I would suggest keeping it simple and just using org-babel-load-file:

I would suggest renaming the org file to something like config.org and have an init.el that contains only

;; init.el (org-babel-load-file (concat user-emacs-directory "config.org")) 

This creates a file config.el by tangling config.org and loads it. My real config is in config.org. I chose that name simply because it avoids confusion between the init.el that you wrote and the one generated by tangling init.org.

You can version-control config.org and put config.el in your gitignore.

In your config.org (or any other name that isn't init.org) you can also put this

(setq custom-file (concat user-emacs-directory "custom-file.el")) (unless (file-exists-p custom-file) (write-region "" nil custom-file)) (load custom-file) 

and gitignore custom-file.el (or your choice of filename).

If you do that, emacs will not change your init.el meaning that you can version control it too and you don't have to do git update-index --assume-unchanged init.el which has drawbacks.

This is missing her tangle-init that runs automatically tangles the file when you save it but it's going to get tangled anyway when you startup Emacs.