Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #+PROPERTY: header-args:emacs-lisp :tangle ./tangled.el
- Welcome to tangling elisp out of org files! I swear it's easier than it sounds.
- Save this as an org file in your .emacs.d directory, put point in the first block, and use =C-c C-c= to evaluate it.
- Then you can put your entire init.el in the second code block, and saving this file should create a new file, =tangled.el= with the provided code and your current config. Now break your config up into blocks and sort them with org headlines and text descriptions!
- Make sure you test that the generated file can be evaluated (=M-x eval-buffer=) and then change the output target in the PROPERTY line at the top to be =./init.el=.
- #+begin_src emacs-lisp
- (org-babel-do-load-languages
- 'org-babel-load-languages '((emacs-lisp . t))) ;; have babel highlight elisp
- (setq org-confirm-babel-evaluate nil) ;; C-c C-c to evaluate code blocks without requesting confirmation
- ;; string expander for code blocks
- (require 'org-tempo)
- ;; Type <el TAB to automatically insert an elisp code block
- ;; it will look like "#+begin_src emacs-lisp" and "#+end_src"
- (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
- (defun my/org-babel-tangle-config ()
- "When saving the org file, automatically tangle it into an elisp file without prompting for confirmation."
- (when (string-equal (buffer-file-name)
- (expand-file-name "~/.emacs.d/config.org")) ; Change this to be whatever you name your org file
- (let ((org-confirm-babel-evaluate nil))
- (org-babel-tangle))))
- (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'my/org-babel-tangle-config)))
- #+end_src
- You can put your current configuration in here:
- #+begin_src emacs-lisp
- ;; Right here!
- #+end_src
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement