emacs.el
Table of Contents
Work in progress, there will be errors
Currently there is an issue with org-mode verions…
1. installation
(org-babel-tangle) (let ((dir (file-name-directory (buffer-file-name))) (target "~/.config/emacs-org/src")) (delete-file "~/.emacs.d/init.el") (make-directory "~/.config/emacs-org/" t) (cond ; ((file-directory-p target) (delete-directory target t)) ((file-symlink-p target) (delete-file target))) (make-symbolic-link dir target t) (make-symbolic-link (concat dir "init.el") "~/.emacs.d/init.el" t)) (message "emacs conf bootstrapped, please relaunch emacs")
2. init
(when (version< "27" emacs-version) (message "version OK") (setq package-enable-at-startup nil)) (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (straight-use-package 'org) (straight-use-package 'use-package)
(require 'org) (message "hello") (org-babel-load-file "~/.config/emacs-org/src/index.org")
3. context
throughout loading our configs we'll need to know whether to enable certain elements. This sets up all predicates for any kind of selection we'll need. We start off with a few indicators as to which kind of device we're dealing with.
(intern "my/phone") (intern "my/laptop") (intern "my/uconsole") (intern "my/boox") (intern "my/unknown")
(defconst my/device-type (let ((phone (file-exists-p "~/.DEVICE_PHONE")) (boox (file-exists-p "~/.DEVICE_BOOX")) (hostname (system-name))) (cond (phone 'my/phone) (boox 'my/boox) ((string= hostname "jeroen-XPS-9320") 'my/laptop) (t 'my/unknown)))) (defun my/device-phone-p () (eq my/device-type 'my/phone)) (defun my/device-laptop-p () (eq my/device-type 'my/laptop)) (defun my/device-boox-p () (eq my/device-type 'my/boox)) (defun my/prefer-light-p () (my/device-boox-p))
We'll also want to know if there's a window manager available.
(defun my/window-manager-p () (and (display-graphic-p) (progn (when (get-buffer " *window-manager*") (kill-buffer " *window-manager*")) (when (get-buffer " *window-manager-error*") (kill-buffer " *window-manager-error*")) (when (executable-find "wmctrl") (shell-command "wmctrl -m ; echo $?" " *window-manager*" " *window-manager-error*")) (eq nil (get-buffer " *window-manager-error*")))))
4. org babel
We'll be loading different org files for parsing so let's make it easy and less error sensitive, so if one file fails, it won't take down the rest of the execution.
(defconst my/emacs-org-conf-basepath "~/.config/emacs-org/src/") (defun my/emacs-org-load-file (filename) "" (condition-case err (org-babel-load-file (concat my/emacs-org-conf-basepath filename)) ((debug error) (progn (message (format "Error loading org-file: %S (%s)\n" err filename)) (with-current-buffer (get-buffer-create "*org-load-errors*") (goto-char (point-max)) (insert (format "Error loading org-file: %S (%s)\n" err filename)) (insert (with-temp-buffer (backtrace) (buffer-string))))))))
5. exwm
- config
- exwm.org
Code specific to exwm, should only be included at specific situations.
(when (and (not (my/device-phone-p)) (display-graphic-p) (not (my/window-manager-p))) (message "exwm eligable to boot") (my/emacs-org-load-file "exwm.org"))
6. interface
(my/emacs-org-load-file "interface.org")
7. org
(my/emacs-org-load-file "org.org")
8. generic development
(my/emacs-org-load-file "development.org")