emacs/init.org

2.2 KiB

Setup Crafted Emacs User Configuration File

Basic configuration

Set import directories for crafted-emacs

  ;;; init.el -- Fschl Crafted Emacs user customization file -*- lexical-binding: t; -*-
  ;; This file is generated from init.org. If you want to edit the
  ;; configuration, DO NOT edit init.el, edit init.org, instead.

  (setq user-emacs-directory "~/.config/crafted-emacs-configdir/")
  (setq crafted-emacs-home "~/src/crafted-emacs/")
  (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
  (when (and custom-file
             (file-exists-p custom-file))
    (load custom-file nil :nomessage))

  (load (expand-file-name "modules/crafted-init-config" crafted-emacs-home))

Add selected crafted-emacs packages

  (require 'crafted-completion-packages)
  (require 'crafted-evil-packages)
  (require 'crafted-org-packages)
  (require 'crafted-ui-packages)
  (require 'crafted-ide-packages)

  (package-install-selected-packages :noconfirm)

Load selected crafted-emacs packages

  (require 'crafted-defaults-config)
  (require 'crafted-startup-config)
  (require 'crafted-completion-config)
  (require 'crafted-evil-config)
  (require 'crafted-org-config)
  (require 'crafted-ui-config)
  (require 'crafted-ide-config)

  (unless crafted-startup-inhibit-splash
    (setq initial-buffer-choice #'crafted-startup-screen))

Auto-tangle on save

Whenever you edit init.org in Emacs and save it, it updates init.el in the same directory.

See the Org Manual for details and alternatives.

  ;; Tangle the code blocks to config.el on save.
  (defun org-babel-tangle-config ()
    (when (string-equal (buffer-file-name)
                        (expand-file-name "init.org" user-emacs-directory))
      ;; Dynamic scoping to the rescue
      (let ((org-confirm-babel-evaluate nil))
        (org-babel-tangle))))

  (add-hook 'org-mode-hook
            (lambda ()
              (add-hook 'after-save-hook #'org-babel-tangle-config)))