Skip to content

Instantly share code, notes, and snippets.

@secemp9
Created December 14, 2024 16:32
Show Gist options
  • Save secemp9/6fd3a73842ebe176d884560d35217b38 to your computer and use it in GitHub Desktop.
Save secemp9/6fd3a73842ebe176d884560d35217b38 to your computer and use it in GitHub Desktop.
org mode style init.el (POC 1)
;; Process org blocks and continue initialization
(ignore-errors
(catch 'init-done
(let* ((init-file (or load-file-name buffer-file-name))
(temp-file (concat temporary-file-directory "init-processed.el")))
;; Extract elisp blocks to temp file
(with-temp-file temp-file
(insert-file-contents init-file)
(goto-char (point-min))
(let ((blocks ""))
(while (re-search-forward "^[ \t]*#\\+BEGIN_SRC[ \t]+emacs-lisp" nil t)
(let ((block-start (point)))
(when (re-search-forward "^[ \t]*#\\+END_SRC" nil t)
(setq blocks (concat blocks "\n"
(buffer-substring-no-properties block-start (match-beginning 0)))))))
(erase-buffer)
(insert blocks)))
;; Load the processed file and exit
(load temp-file)
(throw 'init-done t))))
#+BEGIN_SRC emacs-lisp
;; Your actual init configuration goes here
(setq inhibit-startup-message t)
(menu-bar-mode -1)
(tool-bar-mode -1)
#+END_SRC
#+BEGIN_SRC emacs-lisp
;; More configuration
(global-display-line-numbers-mode 1)
(load-theme 'tango-dark t)
#+END_SRC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment