One Dotfile to rule them all!

I use org-mode’s support for Literate Programming to have all my dotfiles contained in a single file which tangles the code blocks into the correct destinations. Theoretically this should make it easier to get setup on new systems, but more importantly, it makes documenting my config easier.

Adding the following to the top of the file will tangle on save:

org code
# -*- eval: (add-hook 'after-save-hook (lambda nil (org-babel-tangle)) nil t); -*-



emacs-lisp code
;; -*- mode: emacs-lisp; lexical-binding: t; -*-
; Do not edit this file directly!
; This file was generated by running ~org-babel-tangle~ on


(native-compile-async “~/.emacs.d/straight/build/magit/”)

emacs-lisp code
(setenv "LIBRARY_PATH" "/nix/store/qx9kbwz4xk7cdpv1cq42ma5865h8glfn-gcc-9.3.0-lib/lib:/nix/store/02r8mvpnbyp6286hls4zzixc6kv7w3xk-glibc-2.30/lib:/nix/store/kq3hwnp0bdia9ld9445fy829laf46vaf-libgccjit-9.3.0/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/")
(setq comp-deferred-compilation-black-list '("jupyter/.*.el"))
(setq comp-deferred-compilation t)



emacs-lisp code
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
         'silent 'inhibit-cookies)
      (goto-char (point-max))
  (load bootstrap-file nil 'nomessage))

setup use-package

emacs-lisp code
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)


emacs-lisp code
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)

(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)

(require 'saveplace)
(setq-default save-place t)

(show-paren-mode 1)
(setq-default indent-tabs-mode nil)
(setq save-interprogram-paste-before-kill t
      apropos-do-all t
      require-final-newline t
      load-prefer-newer t
      ediff-window-setup-function 'ediff-setup-windows-plain
      save-place-file (concat user-emacs-directory "places")
      backup-directory-alist `(("." . ,(concat user-emacs-directory

(blink-cursor-mode 0)
;; When emacs asks for "yes" or "no", let "y" or "n" suffice
(fset 'yes-or-no-p 'y-or-n-p)
(setq inhibit-startup-message t)
(setq ring-bell-function 'ignore)
(setq confirm-kill-emacs 'yes-or-no-p)
(setq-default fill-column 80)
(setq c-basic-offset 4)

(setq auth-source-save-behavior nil)


emacs-lisp code
(add-to-list 'default-frame-alist
             '(font . "DejaVu Sans Mono 11"))
             ;;'(font . "Menlo-12"))

(use-package spacemacs-common
  (load-theme 'spacemacs-dark t)
  :straight spacemacs-theme)

(use-package all-the-icons)


emacs-lisp code
(use-package spaceline


emacs-lisp code
(global-hl-line-mode t)
(make-variable-buffer-local 'global-hl-line-mode)
(add-hook 'vterm-mode-hook (lambda () (setq global-hl-line-mode nil)))


emacs-lisp code
;;(use-package smooth-scrolling
;;  :config
;;  (smooth-scrolling-mode 1)
;;  (setq smooth-scroll-margin 5)
;;  )


emacs-lisp code
(use-package general
  ;;(general-evil-setup t)
  ;; :keymaps 'normal
  ;; :prefix "SPC"
  ;; "SPC" 'helm-M-x
  ;; "f"  '(:ignore t :which-key "files")
  ;; "ff" 'helm-find-files
  ;; )
  ;;(define-key key-translation-map (kbd "C-h") (kbd "<DEL>"))
  ;; "C-h" 'evil-delete-backward-char-and-join)
    ;;:keymaps 'override
   "C-h" (general-simulate-key "<backspace>"))

   :keymaps 'exwm-mode-map
   "C-h" nil)
  ;;  :states '(normal insert visual motion)
  ;;(global-set-key (kbd "s-<tab>") '(lambda () 
  ;;                                   (interactive) (switch-to-buffer nil)))
    ;;:keymaps 'override
    :keymaps '(override exwm-mode-map)
    "C-<tab>" '(lambda () (interactive)
                 (switch-to-buffer nil)))
                 ;;(switch-to-buffer (other-buffer (current-buffer) t))))

  (general-define-key :keymaps '(override exwm-mode-map) "M-<tab>" 'ace-window)

  ;;(add-hook 'org-mode-hook
  ;;          '(lambda ()
  ;;             (define-key org-mode-map (kbd "M-<tab>") nil)))
  ;;(add-hook 'org-mode-hook
  ;;          '(lambda ()
  ;;             (define-key org-mode-map (kbd "C-<tab>") nil)))
  ;;(add-hook 'eshell-mode-hook
  ;;          '(lambda ()
  ;;             (define-key eshell-mode-map (kbd "M-<tab>") nil)))
  ;;(add-hook 'magit-mode-hook
  ;;          '(lambda ()
  ;;             (define-key magit-mode-map (kbd "M-<tab>") nil)))

  (defun my-start-app (command) 
    (interactive (list (read-shell-command "$ ")))
    (start-process-shell-command command nil command))

  (defun my-toggle-window-split ()
    (if (eq (count-windows) 1)
          (other-window 1)
          (switch-to-buffer nil)
          (other-window 1))

  (general-create-definer my-leader-def
    :prefix "SPC"
    ;;:global-prefix "C-SPC"
    :prefix-command 'my-leader-prefix-cmd
    :states '(normal visual motion)
    :keymaps 'override)

    :keymaps '(override exwm-mode-map)
    "C-SPC" 'my-leader-prefix-cmd)

  (general-create-definer my-local-leader-def
    :prefix ","
    :states '(normal visual motion)
    :keymaps 'override)
    "SPC" 'execute-extended-command
    "u" 'universal-argument
    "'" 'vterm
    "a"  '(:ignore t :which-key "apps")
    "as"  '(:ignore t :which-key "shell")
    "ase" 'eshell
    "ass" 'shell
    "ast" 'ansi-term
    "asv" 'vterm
    "w"  '(:ignore t :which-key "windows")
    "ww" 'my-toggle-window-split
    "w/" 'split-window-right
    "w-" 'split-window-below
    "w=" 'balance-windows
    "wd" 'delete-window
    "b"  'switch-to-buffer
    "C-b"  'switch-to-buffer
    ;;"c"  '(:ignore t :which-key "cd")
    "c"  '(:ignore t :which-key "buffers")
    "cc" 'ibuffer
    "ck" 'kill-current-buffer
    "cu" 'revert-buffer
    "cd" 'cd
    "q"  '(:ignore t :which-key "quit")
    "qq" 'save-buffers-kill-emacs
    "f"  '(:ignore t :which-key "files")
    "ff" 'find-file
    "fs" 'save-buffer
    "fa" 'save-some-buffers
    ;;"h"  'help
    "h"  '(:ignore t :which-key "help")
    "hh" 'describe-symbol
    "hm" 'describe-mode
    "hk" 'describe-key
    "hf" 'describe-function
    "hv" 'describe-variable
    "hb" 'describe-bindings
    "j"  '(:ignore t :which-key "jump")
    "ji" 'imenu
    "s"  '(:ignore t :which-key "search")
    "e" 'my-start-app
    "z" 'describe-bindings
  ;;(general-define-key "s-b" 'switch-to-buffer)
  ;;(general-define-key "s-u" 'revert-buffer)


emacs-lisp code
(use-package evil
  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)
  (setq-default evil-move-cursor-back nil
                evil-want-C-u-scroll t
;;                evil-want-minibuffer t
                evil-want-C-i-jump nil)
  (setq evil-normal-state-cursor '(box "DarkGoldenrod2")
        evil-insert-state-cursor '((bar . 2) "chartreuse3")
        evil-emacs-state-cursor '(box "SkyBlue2")
        evil-hybrid-state-cursor '((bar . 2) "SkyBlue2")
        evil-replace-state-cursor '((hbar . 2) "chocolate")
        evil-evilified-state-cursor '(box "LightGoldenrod3")
        evil-visual-state-cursor '((hbar . 2) "gray")
        evil-motion-state-cursor '(box "plum3")
        evil-lisp-state-cursor '(box "HotPink1")
        evil-iedit-state-cursor '(box "firebrick1")
        evil-iedit-insert-state-cursor '((bar . 2) "firebrick1")
  (evil-mode 1)
  (evil-set-initial-state 'term-mode 'emacs)
  (define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line)
  (define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)
(use-package evil-collection
  :after evil
(use-package evil-matchit
  :after evil
  (global-evil-matchit-mode 1))
(use-package evil-surround
  :after evil
  (global-evil-surround-mode 1))


emacs-lisp code
(use-package ivy
  (setq ivy-use-virtual-buffers t)
  (setq enable-recursive-minibuffers t)
  (setq ivy-count-format "(%d/%d) ")
  (setq ivy-height 20)
  (ivy-mode 1)
    :keymaps 'ivy-minibuffer-map
    "C-<return>" 'ivy-immediate-done

  ;(defun ivy-switch-to-exwm-action (x)
  ;  (with-ivy-window
  ;    (exwm-workspace-switch-to-buffer x)))

  ; 'ivy-switch-buffer
  ; '(("e" ivy-switch-to-exwm-action "exwm"))
  ; )

  ;(defun ivy-call-action-key (key)
  ;  (lambda ()
  ;    (interactive)
  ;    (ivy-exit-with-action
  ;     (cadr
  ;      (assoc key
  ;             (cdr (ivy-state-action ivy-last)))))))

  ;(defun my-ivy-call-exwm ()
  ;    (interactive)
  ;    (ivy-exit-with-action
  ;     (cadr
  ;      (assoc "e"
  ;             (cdr (ivy-state-action ivy-last))))))

  ;(defun my-ivy-exwm-switch-buffer ()
  ;  (interactive)
  ;  (let ((ivy-inhibit-action t))
  ;    (exwm-workspace-switch-to-buffer (ivy-switch-buffer))))

(use-package ivy-hydra

(use-package counsel
  (counsel-mode 1)
  (my-leader-def "sa" 'counsel-ag)
  (my-leader-def "fg" 'counsel-git)

(use-package swiper
  (general-define-key "C-s" 'swiper)
  (my-leader-def "ss" 'swiper)

(use-package amx

;; inspired by
(use-package ivy-rich
  (setq ivy-rich-parse-remote-buffer nil)
  ;;(setq ivy-format-function #'ivy-format-function-line)
  (defun ivy-rich-switch-buffer-exwm-or-project (candidate)
        (get-buffer candidate)
      (if (derived-mode-p 'exwm-mode)
        (ivy-rich-switch-buffer-project candidate))))

  (setq ivy-rich-display-transformers-list
           ((ivy-rich-candidate (:width 60))
            (ivy-rich-switch-buffer-size (:width 7))
            (ivy-rich-switch-buffer-indicators (:width 4 :face error :align right))
            (ivy-rich-switch-buffer-major-mode (:width 18 :face warning))
            (ivy-rich-switch-buffer-exwm-or-project (:width 15 :face success))
            (ivy-rich-switch-buffer-path (:width (lambda (x) (ivy-rich-switch-buffer-shorten-path x (ivy-rich-minibuffer-width 0.3))))))
           (lambda (cand) (get-buffer cand)))
           ((counsel-M-x-transformer (:width 40))
            (ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
           ((counsel-describe-function-transformer (:width 40))
            (ivy-rich-counsel-function-docstring (:face font-lock-doc-face))))
           ((counsel-describe-variable-transformer (:width 40))
            (ivy-rich-counsel-variable-docstring (:face font-lock-doc-face))))
           ((ivy-rich-candidate (:width 0.8))
            (ivy-rich-file-last-modified-time (:face font-lock-comment-face))))))
  (ivy-rich-mode 1)


emacs-lisp code
(use-package avy
  ;; "jj" 'evil-avy-goto-char-timer
  ;; )
  (setq avy-all-windows nil)
  (setq avy-keys '(?a ?o ?e ?u ?h ?t ?n ?s))
  (general-define-key :states 'normal "gc" 'evil-avy-goto-char-timer);;evil-avy-goto-char-2)
(use-package ace-link
  (general-define-key :states 'normal :keymaps 'Info-mode-map "o" 'ace-link-info)
  (general-define-key :states 'normal :keymaps 'help-mode-map "o" 'ace-link-help)
  (general-define-key :states 'normal :keymaps 'help-mode-map "o" 'ace-link-help)
  (my-local-leader-def :keymaps 'org-mode-map "o" 'ace-link-org)
(use-package ace-window
  ;;(general-define-key "C-o" 'ace-buffer)
  (setq aw-keys '(?h ?t ?n ?s))
  ;;(general-define-key :keymaps 'override "M-<tab>" 'ace-window)
  ;; "o" 'ace-window
  ;; )


emacs-lisp code
(use-package ibuffer
  :straight nil
    :states 'normal
    :keymaps 'ibuffer-mode-map
    "<tab>" 'ibuffer-visit-buffer-other-window-noselect)


emacs-lisp code
(setq delete-by-moving-to-trash t)
(setq trash-directory "~/.Trash")

(setq dired-listing-switches "-alhv")
(setq dired-guess-shell-alist-user
      (list (list "\\.pdf" "open")))
(put 'dired-find-alternate-file 'disabled nil)

  :keymaps 'dired-mode-map
  :states 'normal
  "gj" 'dired-next-subdir
  "gk" 'dired-prev-subdir


emacs-lisp code
(use-package yasnippet
  (yas-global-mode 1)


emacs-lisp code
(use-package company
    ;;company-dabbrev-downcase nil
    company-idle-delay 0)
  (company-mode 1)
  (add-hook 'after-init-hook 'global-company-mode)
  (define-key company-active-map (kbd "C-h") nil)


emacs-lisp code
(use-package pdf-tools
  :mode (("\\.pdf\\'" . pdf-view-mode))
  (evil-collection-define-key 'normal 'pdf-view-mode-map
    "u" 'pdf-view-scroll-down-or-previous-page
    "d" 'pdf-view-scroll-up-or-next-page
    "J" 'pdf-view-next-page-command
    "K" 'pdf-view-previous-page-command
    "<right>" 'image-forward-hscroll
    "<left>" 'image-backward-hscroll
    (kbd "C-u") 'pdf-view-scroll-down-or-previous-page
    (kbd "C-d") 'pdf-view-scroll-up-or-next-page
    (kbd "C-s") 'pdf-occur
  (add-hook 'pdf-view-mode-hook #'pdf-links-minor-mode)
  (setq pdf-annot-activate-created-annotations t)
  (setq pdf-annot-default-annotation-properties
        `((t (label . ,user-full-name))
          (text (icon . "Comment")
                (color . "#ff0000"))
          (highlight (color . "yellow"))
          (squiggly (color . "orange"))
          (strike-out(color . "red"))
          (underline (color . "blue"))))


emacs-lisp code
(use-package flyspell
  :straight nil
  (setq ispell-program-name "aspell")
  (add-hook 'org-mode-hook 'flyspell-mode)
  (add-hook 'message-mode-hook 'flyspell-mode)
(use-package flyspell-correct-ivy
    "sc" 'flyspell-correct-wrapper


emacs-lisp code
(use-package which-key


emacs-lisp code
(use-package magit
   "g"  '(:ignore t :which-key "git")
   "gs" 'magit-status
  (define-key magit-mode-map (kbd "C-<tab>") nil)
  (define-key magit-mode-map (kbd "M-<tab>") nil)
(use-package evil-magit



emacs-lisp code
(use-package org
  :straight org-plus-contrib
  (setq org-agenda-files (list "~/org/")
        org-agenda-span 10
        org-edit-src-content-indentation 0
        org-agenda-window-setup 'current-window
        org-startup-with-inline-images nil
        org-src-tab-acts-natively t
        org-adapt-indentation nil
        org-src-window-setup 'current-window
        org-export-with-smart-quotes t
        org-log-done t
        ;;org-src-window-setup 'other-window
        ;;org-export-in-background t
        org-startup-folded t
        org-highlight-latex-and-related '(native latex scripts entities)
  ;; TODO: fix this so org-scheduled today actually applied correctly in org-faces.el
  ;; (- 1 (/ (float diff) (max wdays 0)))
  ;;   (upcoming? (and today? (> deadline today)))
  (setq org-deadline-warning-days 0)
  (setq org-agenda-deadline-faces '((1.01 . org-scheduled-previously)
                                    (1.0 . org-scheduled)
                                    (0.99 . org-sheduled-today)
                                    (0.0 . org-scheduled)))

  (setq org-confirm-babel-evaluate nil)
  ;; display/update images in the buffer after I evaluate
  (add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)

  (evil-define-key 'normal org-mode-map (kbd "RET") 'org-open-at-point)
  (add-to-list 'org-src-lang-modes '("conf" . conf))
  ;;(require 'ox-latex)
  ;;(require 'ox-beamer)
  ;;(setq org-export-allow-bind-keywords t)
  ;;(add-to-list 'org-latex-packages-alist '("" "minted")) added by custom instead
  ;;(ox-extras-activate '(ignore-headlines))
  (setq org-latex-listings 'minted)

  (setq org-latex-packages-alist '(("" "lmodern" nil)
                                   ("" "minted" nil)
                                   ("" "svg" nil)))
                                   ;;("margin=1in,headsep=0.4in,headheight=14pt" "geometry" nil)
                                   ;;("" "geometry" nil)
                                   ;;("" "fancyhdr" nil)
                                   ;;("" "parskip" nil)))
  ;;(setq org-file-apps
  ;;      '((auto-mode . emacs)
  ;;        ("\\.mm\\'" . default)
  ;;        ("\\.x?html?\\'" . default)
  ;;        ("\\.pdf\\'" . default)
  ;;        ("\\.png\\'" . "open \"%s\"")
  ;;        ("\\.svg\\'" . "open \"%s\"")))

  ;;(setq org-latex-pdf-process
  ;;      '("%latex -interaction nonstopmode -shell-escape -output-directory %o %f" "%latex -interaction nonstopmode -shell-escape -output-directory %o %f" "%latex -interaction nonstopmode -shell-escape -output-directory %o %f"))
  (setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
  (setq org-latex-table-scientific-notation "$%s\\times10^{%s}$")
  ;;(setq org-preview-latex-default-process 'imagemagick)
  (setq org-preview-latex-default-process 'dvisvgm
        org-preview-latex-image-directory "~/.cache/org-preview-latex/")

  (defun my-org-format-web-link ()
    (let ((el (org-element-context)))
      (when (and (eq (org-element-type el) 'link)
                 (let ((type (org-element-property :type el)))
                   (or (string= type "http") (string= type "https"))))
        (let* ((url (org-element-property :raw-link el))
               (title (with-current-buffer (url-retrieve-synchronously url)
                          (libxml-parse-html-region (point-min) (point-max))
          (delete-region (org-element-property :begin el)
                         (org-element-property :end el))
          (insert (org-link-make-string url title))))))

   :keymaps 'org-mode-map
   "'" 'org-edit-special
   "c" 'org-capture

   "l" 'org-latex-export-to-pdf
   "h" 'org-latex-export-to-html

   ;; Clock
   ;; These keybindings should match those under the "aoC" prefix (below)
   "Cc" 'org-clock-cancel
   "Cd" 'org-clock-display
   "Ce" 'org-evaluate-time-range
   "Cg" 'org-clock-goto
   "Ci" 'org-clock-in
   "CI" 'org-clock-in-last
   "Cj" 'spacemacs/org-clock-jump-to-current-clock
   "Co" 'org-clock-out
   "CR" 'org-clock-report
   "Cr" 'org-resolve-clocks

   "dd" 'org-deadline
   "ds" 'org-schedule
   "dt" 'org-time-stamp
   "dT" 'org-time-stamp-inactive
   "ee" 'org-export-dispatch
   "fi" 'org-feed-goto-inbox
   "fu" 'org-feed-update-all

   "a" 'org-agenda

   "p" 'org-priority

   "Tc" 'org-toggle-checkbox
   "Te" 'org-toggle-pretty-entities
   "Ti" 'org-toggle-inline-images
   "Tl" 'org-toggle-link-display
   "Tt" 'org-show-todo-tree
   "TT" 'org-todo
   "TV" 'space-doc-mode
   "Tx" 'org-latex-preview
   ;;    "o" 'org-toggle-latex-fragment

   ;; More cycling options (timestamps, headlines, items, properties)
   "L" 'org-shiftright
   "H" 'org-shiftleft
   "J" 'org-shiftdown
   "K" 'org-shiftup

   ;; Change between TODO sets
   "C-S-l" 'org-shiftcontrolright
   "C-S-h" 'org-shiftcontrolleft
   "C-S-j" 'org-shiftcontroldown
   "C-S-k" 'org-shiftcontrolup

   ;; Subtree editing
   "sa" 'org-toggle-archive-tag
   "sA" 'org-archive-subtree
   "sb" 'org-tree-to-indirect-buffer
   "sh" 'org-promote-subtree
   "sj" 'org-move-subtree-down
   "sk" 'org-move-subtree-up
   "sl" 'org-demote-subtree
   "sn" 'org-narrow-to-subtree
   "sN" 'widen
   "sr" 'org-refile
   "ss" 'org-sparse-tree
   "sS" 'org-sort

   ;; tables
   "ta" 'org-table-align
   "tb" 'org-table-blank-field
   "tc" 'org-table-convert
   "tdc" 'org-table-delete-column
   "tdr" 'org-table-kill-row
   "te" 'org-table-eval-formula
   "tE" 'org-table-export
   "th" 'org-table-previous-field
   "tH" 'org-table-move-column-left
   "tic" 'org-table-insert-column
   "tih" 'org-table-insert-hline
   "tiH" 'org-table-hline-and-move
   "tir" 'org-table-insert-row
   "tI" 'org-table-import
   "tj" 'org-table-next-row
   "tJ" 'org-table-move-row-down
   "tK" 'org-table-move-row-up
   "tl" 'org-table-next-field
   "tL" 'org-table-move-column-right
   "tn" 'org-table-create
   "tN" 'org-table-create-with-table.el
   "tr" 'org-table-recalculate
   "ts" 'org-table-sort-lines
   "ttf" 'org-table-toggle-formula-debugger
   "tto" 'org-table-toggle-coordinate-overlays
   "tw" 'org-table-wrap-region

   ;; Source blocks / org-babel
   "bp" 'org-babel-previous-src-block
   "bn" 'org-babel-next-src-block
   "be" 'org-babel-execute-maybe
   "bo" 'org-babel-open-src-block-result
   "bv" 'org-babel-expand-src-block
   "bu" 'org-babel-goto-src-block-head
   "bg" 'org-babel-goto-named-src-block
   "br" 'org-babel-goto-named-result
   "bb" 'org-babel-execute-buffer
   "bs" 'org-babel-execute-subtree
   "bd" 'org-babel-demarcate-block
   "bt" 'org-babel-tangle
   "bf" 'org-babel-tangle-file
   "bc" 'org-babel-check-src-block
   "bj" 'org-babel-insert-header-arg
   "bl" 'org-babel-load-in-session
   "bi" 'org-babel-lob-ingest
   "bI" 'org-babel-view-src-block-info
   "bz" 'org-babel-switch-to-session
   "bZ" 'org-babel-switch-to-session-with-code
   "ba" 'org-babel-sha1-hash
   "bx" 'org-babel-do-key-sequence-in-edit-buffer
   "vk" 'org-babel-remove-result-one-or-many
   "vm" 'org-babel-mark-block

   ;; Multi-purpose keys
   "," 'org-ctrl-c-ctrl-c
   "*" 'org-ctrl-c-star
   "-" 'org-ctrl-c-minus
   "#" 'org-update-statistics-cookies
   "RET"   'org-ctrl-c-ret
   "M-RET" 'org-meta-return
   ;; attachments
   "A" 'org-attach
   ;; insertion
   "ib" 'org-insert-structure-template
   "id" 'org-insert-drawer
   "ie" 'org-set-effort
   "if" 'org-footnote-new
   "ih" 'org-insert-heading
   "iH" 'org-insert-heading-after-current
   "iK" 'spacemacs/insert-keybinding-org
   "il" 'org-insert-link
   "iL" 'org-ref-insert-link
   "in" 'org-add-note
   "ip" 'org-set-property
   "is" 'org-insert-subheading
   "it" 'org-set-tags-command
   "ii" 'my-org-format-web-link

   ;; org-agenda
   "ao#" 'org-agenda-list-stuck-projects
   "ao/" 'org-occur-in-agenda-files
   "aoa" 'org-agenda-list
   "aoc" 'org-capture
   "aoe" 'org-store-agenda-views
   "aofi" 'org-feed-goto-inbox
   "aofu" 'org-feed-update-all
   "aol" 'org-store-link
   "aom" 'org-tags-view
   "aoo" 'org-agenda
   "aos" 'org-search-view
   "aot" 'org-todo-list


emacs-lisp code
(use-package ox-latex
  (add-to-list 'org-latex-minted-langs '(ipython "python"))
  :straight nil

TODO org-bullets


emacs-lisp code
(use-package evil-org
  :after org
  (add-hook 'org-mode-hook 'evil-org-mode)
  (add-hook 'evil-org-mode-hook
            (lambda ()
              (evil-org-set-key-theme '(navigation insert textobjects additional
                                                   calendar todo))))
  (require 'evil-org-agenda)


emacs-lisp code
;(use-package ob-ipython
;  :config
;  (org-babel-do-load-languages
;   'org-babel-load-languages
;   '(
;     (shell . t)
;     (python . t)
;     (ipython . t)
;     (emacs-lisp . t)
;     (latex . t)
;     ))
;  )


emacs-lisp code
; to build using straight on arm:
; cd ~/.emacs.d/straight/build/zmq
; nix-shell -p autoconf automake libtool pkg-config my-zeromq
; make
(use-package jupyter
     (shell . t)
     (python . t)
     (emacs-lisp . t)
     (latex . t)
     (jupyter . t) ; must be last


emacs-lisp code
(use-package htmlize


emacs-lisp code
(use-package org-ref
  (setq reftex-default-bibliography '("~/qnet/notebook/references.bib"))
  (setq org-ref-default-bibliography '("~/qnet/notebook/references.bib")
        org-ref-bibliography-notes "~/qnet/notebook/"
        org-ref-pdf-directory "~/qnet/ref-pdfs/"
        doi-utils-download-pdf nil
        doi-utils-make-notes nil)
        ;;bibtex-completion-notes-path "~/qnet/ref-notes/"
  (setq org-ref-completion-library 'org-ref-ivy-cite)


emacs-lisp code
(use-package org-pdftools
  :straight (org-pdftools :type git :host github :repo "fuxialexander/org-pdftools")
  :config (setq org-pdftools-root-dir "~/qnet/ref-pdfs/")
  (with-eval-after-load 'org
    (org-link-set-parameters "pdftools"
                             :follow #'org-pdftools-open
                             :complete #'org-pdftools-complete-link
                             :store #'org-pdftools-store-link
                             :export #'org-pdftools-export)
    (add-hook 'org-store-link-functions 'org-pdftools-store-link)))


emacs-lisp code
(use-package tex
  :straight auctex
  :defer t
  (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  (setq TeX-view-program-list '(("pdf-tools" "TeX-pdf-tools-sync-view")))
  (add-hook 'TeX-after-compilation-finished-functions
;;(setq TeX-command-extra-options "\"-shell-escape\"")
;;(spacemacs/set-leader-keys-for-major-mode 'tex-mode
;;  "l" 'latex/build)
;;(spacemacs/set-leader-keys-for-major-mode 'latex-mode
;;  "l" 'latex/build)


emacs-lisp code
(add-to-list 'load-path "~/.nix-profile/share/emacs/site-lisp/mu4e/")
(use-package mu4e
  :straight nil
  ;(setq mu4e-mu-binary "/usr/local/share/emacs/site-lisp/mu/mu4e")

   :states 'normal
   :keymaps 'mu4e-view-mode-map
   "o" 'ace-link-mu4e
   "O" 'mu4e-view-open-attachment)

   "am" 'mu4e
  (require 'org-mu4e)
(use-package mu4e-maildirs-extension

TODO nix

fix this so nix-eshell works

emacs-lisp code
(use-package nix-mode

smartparens and rainbow-delimiters

emacs-lisp code
(use-package smartparens
  (sp-local-pair 'org-mode "$" "$")
  (sp-local-pair 'org-mode '"\\[" "\\]")
(use-package rainbow-delimiters
  (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)


emacs-lisp code
(use-package column-enforce-mode
  (add-hook 'prog-mode-hook 'column-enforce-mode)
  (add-hook 'text-mode-hook 'column-enforce-mode)
;;(require 'fill-column-indicator)
;;(add-hook 'prog-mode-hook 'turn-on-fci-mode)
;;(add-hook 'text-mode-hook 'turn-on-fci-mode)

frames and windows

emacs-lisp code
(setq split-height-threshold nil) ;80) ;40)
(setq split-width-threshold nil) ;160) ;100)


emacs-lisp code
(add-hook 'eshell-mode-hook
          '(lambda ()
             (define-key eshell-mode-map (kbd "<tab>") 'completion-at-point)))

(evil-define-key 'insert eshell-mode-map 
  (kbd "C-p") 'eshell-previous-input 
  (kbd "C-n") 'eshell-next-input)


emacs-lisp code
(setq shell-default-height 40)
(setq shell-default-position 'full)
(setq shell-default-full-span nil)
(setq shell-default-term-shell "/usr/local/bin/bash")
;;(setq shell-default-shell 'shell)
(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist)
;;(setq term-color-black ((t (:foreground "dim gray"))))

(evil-define-key 'normal comint-mode-map (kbd "C-p") 'comint-previous-input
  (kbd "C-n") 'comint-next-input)
(evil-define-key 'insert comint-mode-map (kbd "C-p") 'comint-previous-input
  (kbd "C-n") 'comint-next-input)
(evil-define-key 'normal comint-mode-map (kbd "C-l") 'comint-clear-buffer)
(evil-define-key 'insert comint-mode-map (kbd "C-l") 'comint-clear-buffer)
(evil-define-key 'normal term-raw-map (kbd "C-p") 'term-send-up
  (kbd "C-n") 'term-send-down)
(evil-define-key 'insert term-raw-map (kbd "C-p") 'term-send-up
  (kbd "C-n") 'term-send-down)

(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "--simple-prompt")

(setq python-shell-prompt-detect-failure-warning nil)
;;(setq python-shell-completion-native-disabled-interpreters '("jupyter" "pypy"))

;;(add-hook 'shell-mode-hook 'my-shell-mode-hook)
;;(defun my-shell-mode-hook ()
;;  (setq comint-input-ring-file-name "~/.bash_history")
;;  (comint-read-input-ring t))
;;(defun my-shell-mode-hook ()
;;  (let ((histfile  "~/.bash_history"))
;;    (if (tramp-tramp-file-p default-directory)
;;        (let ((vec (tramp-dissect-file-name default-directory)))
;;          (setq comint-input-ring-file-name
;;                (tramp-make-tramp-file-name
;;                 (tramp-file-name-method vec)
;;                 (tramp-file-name-user vec)
;;                 (tramp-file-name-host vec)
;;                 histfile)))
;;      (setq comint-input-ring-file-name histfile)))
;;  (comint-read-input-ring t)
;;  (let ((process (get-buffer-process (current-buffer))))
;;    (set-process-sentinel process #'comint-write-input-ring)))

;; modifid from
;; (add-hook 'term-mode-hook
;;           (lambda ()
;;             (add-hook 'evil-normal-state-entry-hook
;;                       (lambda () (term-line-mode)) nil t)
;;             (add-hook 'evil-normal-state-exit-hook
;;                       (lambda () (term-char-mode)) nil t)))
(setq term-char-mode-point-at-process-mark nil)


emacs-lisp code
; to build using straight:
; cd ~/.emacs.d/straight/build/vterm
; nix-shell -p cmake libvterm-neovim
; make

(use-package vterm


emacs-lisp code
(use-package tramp
  (add-to-list 'tramp-remote-path 'tramp-own-remote-path)

  ;; for some reason (bug probably) this has to be here to reset tram-password-prompt-regexp
  (setq tramp-password-prompt-regexp
        (format "^.*\\(%s\\).*:\^@? *" (regexp-opt password-word-equivalents)))

  :straight nil

(setq password-word-equivalents (cons "token_response" password-word-equivalents))

;;(setq tramp-histfile-override t nil (tramp))

this fixes an issue where you get the error: ppwd: command not found only on macos?


emacs-lisp code
(use-package lua-mode


emacs-lisp code
(use-package json-mode


emacs-lisp code
(defvar-local hidden-mode-line-mode nil)

(define-minor-mode hidden-mode-line-mode
  "Minor mode to hide the mode-line in the current buffer."
  :init-value nil
  :global t
  :variable hidden-mode-line-mode
  :group 'editing-basics
  (if hidden-mode-line-mode
      (setq hide-mode-line mode-line-format
            mode-line-format nil)
    (setq mode-line-format hide-mode-line
          hide-mode-line nil))
  ;; Apparently force-mode-line-update is not always enough to
  ;; redisplay the mode-line
  (when (and (called-interactively-p 'interactive)
     0 nil 'message
     (concat "Hidden Mode Line Mode enabled.  "
             "Use M-x hidden-mode-line-mode to make the mode-line appear."))))

;; If you want to hide the mode-line in every buffer by default
;; (add-hook 'after-change-major-mode-hook 'hidden-mode-line-mode)

brightness ;;(use-package xbacklight ;; :straight (xbacklight :type git :host github :repo “dakra/xbacklight”) ;;) (setq brightness-delta “10%”) (setq brightness-get-cmd “light”) (setq brightness-get-regexp “\\([0-9]+%\\)”) (setq brightness-set-cmd “light set %s”)

(defun brightness-get () (let ((output (shell-command-to-string brightness-get-cmd))) (save-match-data (string-match brightness-get-regexp output) (match-string 1 output))))

(defun brightness-set (value) (shell-command-to-string (format brightness-set-cmd value)) (message “New brightness value: %s” (brightness-get)))

(defun brightness-inc () (interactive) (brightness-set (concat brightness-delta “+”)))

(defun brightness-dec () (interactive) (brightness-set (concat brightness-delta “-”)))

emacs-lisp code
(defun brightness-get ()
  (message "Brightness:  %s%%" 
           (string-trim (shell-command-to-string "light") "%")))

(defun brightness-inc ()
  (shell-command-to-string "light -A 5")

(defun brightness-dec ()
  (shell-command-to-string "light -U 5")


emacs-lisp code
(use-package pulseaudio-control
  (setq pulseaudio-control-volume-step "5%")
    "ap" 'pulseaudio-control-map

(use-package exwm
;;  :straight nil
  (setq use-dialog-box nil)
  (setq exwm-workspace-show-all-buffers t)
  (setq exwm-layout-show-all-buffers t)
  (evil-set-initial-state 'exwm-mode 'emacs)
  (setq my-window-resize-delta 2)
  (setq lockcmd "i3lock -i /home/akyle/Downloads/outrun.png")
  ;;(setq exwm-workspace-minibuffer-position 'bottom)

  ;;(setenv "EDITOR" "emacsclient") set in xinitrc

  ;;(add-hook 'exwm-mode-hook #'hidden-mode-line-mode)

  ;;  "e" '(lambda () (interactive) (xcb:ewmh:set-_NET_WM_DESKTOP)))

  ;; All buffers created in EXWM mode are named "*EXWM*". You may want to
  ;; change it in `exwm-update-class-hook' and `exwm-update-title-hook', which
  ;; are run when a new X window class name or title is available.  Here's
  ;; some advice on this topic:
  ;; + Always use `exwm-workspace-rename-buffer` to avoid naming conflict.
  ;; + For applications with multiple windows (e.g. GIMP), the class names of
  ;;    all windows are probably the same.  Using window titles for them makes
  ;;   more sense.
  ;; In the following example, we use class names for all windows expect for
  ;; Java applications and GIMP.
  ;;(add-hook 'exwm-update-class-hook
  ;;          (lambda ()
  ;;            (unless (or (string-prefix-p "sun-awt-X11-" exwm-instance-name)
  ;;                        (string= "gimp" exwm-instance-name))
  ;;              (exwm-workspace-rename-buffer exwm-class-name))))
  ;;(add-hook 'exwm-update-title-hook
  ;;          (lambda ()
  ;;            (when (or (not exwm-instance-name)
  ;;                      (string-prefix-p "sun-awt-X11-" exwm-instance-name)
  ;;                      (string= "gimp" exwm-instance-name))
  ;;              (exwm-workspace-rename-buffer exwm-title))))

  (defun my-exwm-rename ()
    (exwm-workspace-rename-buffer (concat exwm-class-name ": " exwm-title)))

  (add-hook 'exwm-update-class-hook 'my-exwm-rename)
  (add-hook 'exwm-update-title-hook 'my-exwm-rename)

  ;;(add-hook 'exwm-update-title-hook 
  ;;          (lambda () 
  ;;            (if (and (string= "Firefox" exwm-class-name)
  ;;                     (not (string= "Mozilla Firefox" exwm-title)))
  ;;                ;;(exwm-workspace-rename-buffer (substring exwm-title 0 -18))
  ;;                (exwm-workspace-rename-buffer exwm-title)
  ;;              (exwm-workspace-rename-buffer exwm-title))))
  ;;;; Quick swtiching between workspaces
  ;;(defvar exwm-toggle-workspace 0
  ;;  "Previously selected workspace. Used with `exwm-jump-to-last-exwm'.")
  ;;(defun exwm-jump-to-last-exwm ()
  ;;  (interactive)
  ;;  (exwm-workspace-switch exwm-toggle-workspace))
  ;;(defadvice exwm-workspace-switch (before save-toggle-workspace activate)
  ;;  (setq exwm-toggle-workspace exwm-workspace-current-index))

  (setq touchpad-is-enabled t)
  (defun toggle-touchpad ()
    (if touchpad-is-enabled
          (shell-command "xinput disable 'Pine64 Pinebook Pro Touchpad'")
          (setq touchpad-is-enabled nil))
        (shell-command "xinput enable 'Pine64 Pinebook Pro Touchpad'")
        (setq touchpad-is-enabled t))))

  (general-define-key :keymaps 'override "<f7>" 'toggle-touchpad)

  (define-key exwm-mode-map (kbd "C-c") nil)

  (add-to-list 'exwm-input-prefix-keys (kbd "C-SPC"))

  (setq exwm-input-global-keys
          ([?\s-r] . exwm-reset)
          ;;(,(kbd "C-SPC") . my-leader-prefix-cmd)
          ([?\s-f] . exwm-layout-toggle-fullscreen)
          ([?\s-F] . exwm-layout-toggle-mode-line)
          ([?\s-x] . exwm-workspace-switch)
          ;;([s-tab] . exwm-jump-to-last-exwm)
          ;;(,(kbd "M-<tab>") . exwm-jump-to-last-exwm)
          ;;(,(kbd "M-<tab>") . toggle-window-split)
          ;;(,(kbd "C-<tab>") . (lambda () (interactive) (switch-to-buffer nil)))
          ;;([?\s-b] . switch-to-buffer)
          ;;([?\s-o] . find-file)
          ;;(,(kbd "<f8>") . toggle-touchpad)

          ;;,@(mapcar (lambda (i)
          ;;            `(,(kbd (format "s-%d" i)) .
          ;;              (lambda ()
          ;;                (interactive)
          ;;                (exwm-workspace-switch-create ,i))))
          ;;          (number-sequence 0 9))

          ;; Bind "s-m" to launch applications ('M-&' also works if the output
          ;; buffer does not bother you).
          ;;(,(kbd "s-m") . counsel-linux-app)

          ;;;; Focusing windows
          ;;(,(kbd "s-h") . evil-window-left)
          ;;(,(kbd "s-j") . evil-window-down)
          ;;(,(kbd "s-k") . evil-window-up)
          ;;(,(kbd "s-l") . evil-window-right)
          ;;;; Moving Windows
          ;;(,(kbd "s-H") . evil-window-move-far-left)
          ;;(,(kbd "s-J") . evil-window-move-very-bottom)
          ;;(,(kbd "s-K") . evil-window-move-very-top)
          ;;(,(kbd "s-L") . evil-window-move-far-right)
          ;;;; Resize
          ;;(,(kbd "M-s-h") . (lambda () (interactive) (shrink-window my-window-resize-delta t)))
          ;;(,(kbd "M-s-j") . (lambda () (interactive) (shrink-window my-window-resize-delta)))
          ;;(,(kbd "M-s-k") . (lambda () (interactive) (enlarge-window my-window-resize-delta)))
          ;;(,(kbd "M-s-l") . (lambda () (interactive) (enlarge-window my-window-resize-delta t)))
          (,(kbd "<XF86MonBrightnessDown>") . brightness-dec)
          (,(kbd "<XF86MonBrightnessUp>") . brightness-inc)
          (,(kbd "<XF86AudioMute>") . pulseaudio-control-toggle-current-sink-mute)
          (,(kbd "<XF86AudioLowerVolume>") . pulseaudio-control-decrease-volume)
          (,(kbd "<XF86AudioRaiseVolume>") . pulseaudio-control-increase-volume)
          (,(kbd "s-<escape>") . (lambda () (interactive) (shell-command lockcmd)))
          ;(,(kbd "s-t") . (lambda () (interactive) (start-process "firefox" nil "firefox")))

  (setq my-global-simulation-keys 
          (,(kbd "C-b") . ,(kbd "<left>"))
          (,(kbd "C-f") . ,(kbd "<right>"))
          (,(kbd "C-p") . ,(kbd "<up>"))
          (,(kbd "C-n") . ,(kbd "<down>"))
          (,(kbd "C-a") . ,(kbd "<home>"))
          (,(kbd "C-e") . ,(kbd "<end>"))
          (,(kbd "C-h") . ,(kbd "<backspace>"))
          ;;(,(kbd "s-t") . ,(kbd "C-t"))
          ;;(,(kbd "s-c") . ,(kbd "C-c"))
          ;;(,(kbd "s-v") . ,(kbd "C-v"))
          ;;(,(kbd "s-w") . ,(kbd "C-w"))
          ;;(,(kbd "s-q") . ,(kbd "C-q"))
          ;;(,(kbd "s-n") . ,(kbd "C-n"))
          (,(kbd "C-j") . ,(kbd "C-<prior>"))
          (,(kbd "C-k") . ,(kbd "C-<next>"))

  (setq exwm-input-simulation-keys my-global-simulation-keys)

  ;;(setq my-firefox-simulation-keys
  ;;      (append my-global-simulation-keys
  ;;              `(
  ;;                ;;(,(kbd "s-<tab>") . ,(kbd "C-<tab>"))
  ;;                ;;(,(kbd "s-<tab>") . ,(kbd "^")) ; works with vimperator
  ;;                (,(kbd "s-<tab>") . ,(kbd "C-6")) ; works with tridactyl
  ;;                (,(kbd "C-s") . ,(kbd "C-g")) ; works with tridactyl
  ;;                (,(kbd "C-S-s") . ,(kbd "C-S-g")) ; works with tridactyl
  ;;                )))

  ; c-tab seem like it just wont work given emacs' limitations
  ; exwm-input--fake-key:       id=#x1000037 event=C-tab keycode
  ;[[file:/nix/store/b011yv21rbqr7a35m1prl4jk44cybwxl-emacs-exwm-0.22.1/share/emacs/site-lisp/elpa/exwm-0.22.1/exwm-input.el::(make-instance class]] 

  ;(setq exwm-manage-finish-hook nil)
  ;;(add-hook 'exwm-manage-finish-hook
  ;;        (lambda ()
  ;;          (when (and exwm-class-name
  ;;                     (string= exwm-class-name "Firefox"))
  ;;            (exwm-input-set-local-simulation-keys my-firefox-simulation-keys))))

  ;;(require 'subr-x)  ;; Because of when-let

  ;;(defvar exwm-workspace-window-assignments
  ;;  '(("Firefox" . 0))
  ;;  "An alist of window classes and which workspace to put them on.")

  ;;(add-hook 'exwm-manage-finish-hook
  ;;          (lambda ()
  ;;            (when-let ((target (cdr (assoc exwm-class-name exwm-workspace-window-assignments))))
  ;;              (exwm-workspace-move-window target))))

  ;;(defun my-startup-processes ()
  ;;  (start-process "firefox" nil "firefox")
  ;;  ;;(start-process "calendar" nil "gnome-calendar")
  ;;  )
  ;(add-hook 'exwm-init-hook 'my-startup-processes)

  ;;(defun my-startup-layout ()
  ;;  (interactive)
  ;;  (switch-to-buffer "Firefox")
  ;;  (exwm-workspace-move-window 9)
  ;;  (switch-to-buffer "Gnome-calendar")
  ;;  (exwm-workspace-move-window 8)
  ;;  (exwm-workspace-switch 0)
  ;;  (split-window-right)
  ;;  (setq current-prefix-arg '(4))
  ;;  (call-interactively 'spacemacs/default-pop-shell)
  ;;  (evil-normal-state)
  ;;  (evil-emacs-state)
  ;;  (other-window 1)
  ;;  (org-agenda-list))


  ;;(require 'exwm-randr)
  ;;(setq exwm-randr-workspace-output-plist '(0 "VGA1"))
  ;;(add-hook 'exwm-randr-screen-change-hook
  ;;          (lambda ()
  ;;            (start-process-shell-command
  ;;             "xrandr" nil "xrandr --output VGA1 --left-of LVDS1 --auto")))
  ;;(server-start) ; start emacsclient for xdg-open of pdfs from firefox


emacs-lisp code
(use-package minibuffer-statusbar
  :straight (minibuffer-statusbar :type git :host github 
                                  :repo "akirakyle/minibuffer-statusbar")
  (minibuffer-statusbar-mode t)
  (global-eldoc-mode -1))


bash code
#setxkbmap -layout us -model apple-laptop -variant dvorak -option caps:ctrl_modifier ctrl:ralt_rctrl
#xset m 100 1
#polybar bar &
#xcape -e 'Control_L=Escape'
#xcape -e Caps_Lock=Escape
#libinput-gestures &
xset r rate 150 50
export EDITOR=emacsclient
export PAN_MESA_DEBUG=gles3
export MOZ_USE_XINPUT2=1
export GTK_THEME=Adwaita:dark
xsetroot -cursor_name left_ptr
exec emacs
#exec ~/git/emacs/emacs-build/src/emacs



snippet code
# -*- mode: snippet -*-
# name: general block
# key: 
# --
#+BEGIN_${1:SRC$(upcase yas-text)}
snippet code
# -*- mode: snippet -*-
# name: general block
# key: bl
# --
snippet code
# -*- mode: snippet -*-
# name: ipython block
# key: py
# --
#+begin_src ipython :session ${1::file ${2:./`(file-relative-name (let ((temporary-file-directory "./figs/")) (make-directory temporary-file-directory t) (make-temp-file "ipy" nil ".svg")))`}} :exports ${3:both}
snippet code
# -*- mode: snippet -*-
# name: ipython block
# key: py
# --
#+begin_src ipython :session ${1::ipyfile ${2:} }:exports ${3:both }:results ${4:raw drawer}
snippet code
# -*- mode: snippet -*-
# name: python block
# key: py
# --
#+begin_src jupyter-python
snippet code
# -*- mode: snippet -*-
# name: latex block
# key: beg
# --
snippet code
# -*- mode: snippet -*-
# name: matplotlib imports
# key: mpl
# --
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'svg'
GPG Public Key: 963C 2413 0BD3 BF1B 624C EF4C 8850 284C 20B8 078D