Packages are to be manages by leaf.el.
(eval-and-compile
(customize-set-variable
'package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize)
(unless (package-installed-p 'leaf)
(package-refresh-contents)
(package-install 'leaf))
(leaf leaf-keywords
:ensure t
:init
(leaf el-get :ensure t)
:config
;; initialize leaf-keywords.el
(leaf-keywords-init)))
(leaf leaf-tree :ensure t)
(leaf leaf-convert :ensure t)Perhaps this is a bad habit.
(leaf exec-path-from-shell
:ensure t
:config
(exec-path-from-shell-initialize))Utilities for configurations.
(require 'f)
(require 's)
(require 'cl-lib)
(defun is-the-device (device-name)
(cl-equalp
(s-trim (f-read "~/.machine-name"))
device-name))
(defconst +on-internalblaze+
(is-the-device "internalblaze"))
(defmacro device-case (&rest cases)
`(cond
,@(mapcar (lambda (l)
`((is-the-device ,(car l))
,@(cdr l)))
cases)))Be evil.
(leaf evil
:ensure t
:require t
:after undo-tree
:defvar (evil-want-integration
evil-want-keybinding)
:init
(setf evil-want-integration t)
(setf evil-want-keybinding nil)
:global-minor-mode evil-mode
:custom ((evil-want-Y-yank-to-eol . t)
(evil-shift-width . 4)
(evil-undo-system . 'undo-tree))
:bind ((:evil-insert-state-map
("C-l" . evil-normal-state))
(:evil-visual-state-map
("C-l" . evil-normal-state))
(:evil-normal-state-map
("C-l" . nil))
(:evil-motion-state-map
("j" . evil-next-visual-line)
("k" . evil-previous-visual-line)
("SPC" . nil)
("SPC -" . evil-window-split)
("SPC |" . evil-window-vsplit)
("SPC d f" . describe-function)
("SPC d v" . describe-variable)
("SPC d s" . describe-symbol)
("SPC d k" . describe-key)
("SPC d p" . describe-package)))
:config
(leaf evil-collection
:ensure t
:require t
:custom (evil-collection-key-blacklist . '("C-l"))
:config (evil-collection-init))
(leaf evil-surround
:ensure t
:require t
:global-minor-mode global-evil-surround-mode)
(evil-define-command evil-tab-sensitive-quit (&optional bang)
:repeat nil
(interactive "<!>")
(cond
((> (length (window-list)) 1) (delete-window))
((> (length (tab-bar-tabs)) 1) (tab-bar-close-tab))
(t (evil-quit bang))))
(evil-define-command evil-tab-sensitive-wq (&optional bang)
:repeat nil
(interactive "<!>")
(save-buffer)
(evil-tab-sensitive-quit bang))
(evil-ex-define-cmd "q[uit]" 'evil-tab-sensitive-quit)
(evil-ex-define-cmd "wq" 'evil-tab-sensitive-wq))It’s nice to have a time-machine.
(leaf undo-tree
:ensure t
:require t
:custom ((undo-tree-history-directory-alist
. '(("." . "~/.undo-tree"))))
:global-minor-mode global-undo-tree-mode)(leaf tab-bar
:tag builtin
:global-minor-mode tab-bar-mode
:custom ((tab-bar-show . 1)
(tab-bar-new-tab-choice . "*scratch*"))
:bind ((:evil-motion-state-map
("SPC W" . tab-bar-new-tab)
("SPC w" . tab-bar-select-tab))))(color-theme-sanityinc-tomorrow-eighties) doesn’t prevent asking me “Are you sure?”
(leaf color-theme-sanityinc-tomorrow
:ensure t
:require t
:config
(load-theme 'sanityinc-tomorrow-eighties t))(tool-bar-mode -1)
(scroll-bar-mode -1)
(when +on-internalblaze+
(menu-bar-mode -1))
(setf inhibit-startup-screen t)(setf default-frame-alist
(device-case
("StellarDagger" '((width . 125)
(height . 35)
(left . 200)
(top . 30)
(font . "Ricty Diminished Discord 14")))
("InternalBlaze" '((width . 125)
(height . 40)
(left . 220)
(top . 50)
(font . "Menlo 14")))))(leaf hydra
:ensure t)(leaf counsel
:ensure t
:after evil
:custom ((ivy-use-virtual-buffers . t)
(ivy-count-format . "%d/%d "))
:global-minor-mode ivy-mode
:bind ((:evil-motion-state-map
:package evil
("/" . swiper-isearch-save-direction)
("?" . swiper-isearch-backward-save-direction)
("SPC f" . counsel-find-file)
("SPC F" . counsel-dired-file)
("SPC b" . counsel-switch-buffer)
("SPC h" . counsel-recentf)))
:config
(leaf ivy-hydra
:ensure t)
(defun swiper-isearch-save-direction (&optional initial-input)
"swiper-isearch which saves its direction to isearch-forward"
(interactive)
(swiper-isearch initial-input)
(setf isearch-forward t))
(defun swiper-isearch-backward-save-direction (&optional initial-input)
"swiper-isearch-backward which saves its direction to isearch-forward"
(interactive)
(swiper-isearch-backward initial-input)
(setf isearch-forward nil)))Emacs is too hard to live in without this.
(leaf which-key
:ensure t
:global-minor-mode which-key-mode)(leaf autorevert
:tag "builtin"
:global-minor-mode global-auto-revert-mode)(leaf recentf
:tag "builtin"
:global-minor-mode recentf-mode)(setf backup-directory-alist '(("." . "~/.emacs-backup")))- Typing
greach time you move is cumbersome. lson macOS does not supportls --dired.
(leaf dired
:tag "builtin"
:custom (dired-auto-revert-buffer . t)
:config
(when +on-internalblaze+
(setq insert-directory-program "gls")))(leaf lsp-mode
:ensure t
:hook (lsp-mode-hook . lsp-enable-which-key-integration)
:config
(leaf lsp-ui
:ensure t))(leaf company
:ensure t
:custom ((company-idle-delay . 0))
:global-minor-mode global-company-mode)(leaf flycheck
:ensure t
:global-minor-mode global-flycheck-mode)(leaf yasnippet
:ensure t
:global-minor-mode yas-global-mode
:bind ((:yas-minor-mode-map ("C-c y" . yas-expand)))
:config
(leaf yasnippet-snippets
:ensure t))(leaf magit
:ensure t
:bind ((:evil-motion-state-map
:package evil
("SPC g" . magit-status))))(leaf vterm
:ensure t
:after evil-collection
:bind ((:evil-motion-state-map
:package evil
("SPC r" . vterm-repl)))
:config
(defun vterm-repl (command)
(interactive "sREPL command: ")
(let ((vterm-shell command))
(multi-vterm)))
(leaf multi-vterm
:ensure t
:bind (:evil-motion-state-map
:package evil
("SPC t" . multi-vterm)
("SPC T" . multi-vterm-in-new-tab))
:config
(defun multi-vterm-in-new-tab ()
(interactive)
(tab-bar-new-tab)
(multi-vterm))))(leaf paren
:tag "builtin"
:custom ((show-paren-delay . 0))
:global-minor-mode show-paren-mode)
(leaf elec-pair
:tag "builtin"
:global-minor-mode electric-pair-mode)(leaf display-line-numbers
:tag "builtin"
:global-minor-mode global-display-line-numbers-mode)No tabs, please.
(setq-default indent-tabs-mode nil)How many of them do I use?
(leaf cc-mode
:tag builtin
:custom (c-default-style . '((java-mode . "java")
(awk-mode . "awk")
(other . "linux")))
:hook ((c-mode-hook c++-mode-hook . lsp)
(c-mode-hook . (lambda ()
(setq-local indent-tabs-mode t)))))As far as I tried so far ob-julia-vterm seems to be the best Julia-Babel integration package.
(leaf julia-mode
:ensure t
:config
(leaf lsp-julia
:ensure t
:hook (julia-mode-hook . lsp))
(leaf julia-vterm
:ensure t
:hook (julia-mode-hook . julia-vterm-mode))
(leaf ob-julia-vterm
:el-get (ob-julia-vterm
:url "https://github.com/shg/ob-julia-vterm.el.git")
:after julia-vterm))(leaf python
:tag "builtin"
:custom ((python-shell-interpreter . "python3"))
:hook ((python-mode-hook . lsp)))(leaf ein
:ensure t
:if nil
:custom ((ein:output-area-inlined-images . t)))
(leaf jupyter
:ensure t)(leaf go-mode
:ensure t
:hook (go-mode-hook . lsp))Although there is some support in sh-mode, it does not behave well overall.
(leaf fish-mode
:ensure t)(leaf paredit
:ensure t
:hook ((lisp-mode-hook
emacs-lisp-mode-hook
ielm-mode-hook
hy-mode-hook
scheme-mode-hook)
. enable-paredit-mode))(leaf geiser
:ensure t
:custom ((geiser-default-implementation . 'guile))
:config
(leaf geiser-guile
:ensure t)
(leaf geiser-gauche
:ensure t)
(leaf geiser-kawa
:ensure t)
(leaf geiser-chicken
:ensure t))There seems to be some problems. I’ll face it when the time comes.
(leaf gnuplot
:ensure t
:commands (gnuplot-mode gnuplot-make-buffer)
:init
(add-to-list 'auto-mode-alist '("\\.gp$" . gnuplot-mode)))(leaf auctex
:ensure t
:hook ((LaTeX-mode-hook . LaTeX-math-mode)
(LaTeX-mode-hook . lsp))
:custom ((japanese-TeX-engine-default . 'luatex)
(TeX-default-mode . 'japanese-latex-mode)
(japanese-LaTeX-default-style . "ltjsarticle"))
:config
(leaf lsp-latex
:ensure t
:custom ((lsp-latex-build-on-save . t))))(leaf haskell-mode
:ensure t
:hook (haskell-mode-hook . lsp)
:config
(leaf lsp-haskell
:ensure t
:after lsp-mode))(leaf tuareg
:ensure t
:hook (tuareg-mode-hook . lsp))Let’s org’anize everything.
(leaf org
:tag "builtin"
:after yasnippet company
:custom ((org-agenda-files . "~/.emacs.d/org-agenda")
(org-startup-truncated . nil)
(org-startup-indented . t)
(org-image-actual-width . 500)
(org-latex-compiler . "lualatex")
(org-latex-pdf-process . '("latexmk -output-directory=%o %f"))
(org-latex-packages-alist . '(("" "luatexja-fontspec" nil '("lualatex"))))
(org-latex-default-class . "ltjsarticle")
(org-latex-prefer-user-labels . t)
(org-babel-python-command . "python3")
(org-ditaa-jar-path . "/usr/local/Cellar/ditaa/0.11.0_1/libexec/ditaa-0.11.0-standalone.jar")
(org-confirm-babel-evaluate . nil)
(org-format-latex-header . "
\\documentclass[ja=standard]{bxjsarticle}
\\usepackage[usenames]{color}
[PACKAGES]
[DEFAULT-PACKAGES]
\\pagestyle{empty} % do not remove
\\usepackage{arev}
% The settings below are copied from fullpage.sty
\\setlength{\\textwidth}{\\paperwidth}
\\addtolength{\\textwidth}{-3cm}
\\setlength{\\oddsidemargin}{1.5cm}
\\addtolength{\\oddsidemargin}{-2.54cm}
\\setlength{\\evensidemargin}{\\oddsidemargin}
\\setlength{\\textheight}{\\paperheight}
\\addtolength{\\textheight}{-\\headheight}
\\addtolength{\\textheight}{-\\headsep}
\\addtolength{\\textheight}{-\\footskip}
\\addtolength{\\textheight}{-3cm}
\\setlength{\\topmargin}{1.5cm}
\\addtolength{\\topmargin}{-2.54cm}
"
)
(org-format-latex-options . '(:foreground "White"
:background default
:scale 1.5
:html-foreground "Black"
:html-background "Transparent"
:html-scale 1.0
:matchers ("begin" "$1" "$" "$$" "\\(" "\\[")))
(org-latex-listings . t)
(org-latex-listings-options .
'(("basicstyle" "\\fontspec{RictyDiminished-Discord}")
("keywordstyle" "{\\fontspec{RictyDiminishedDiscord-Bold}[Color=blue]}")
("commentstyle" "{\\fontspec{RictyDiminishedDiscord-Oblique}[Color=green]}")
("stringstyle" "\\color{orange}")
("postbreak" "↳\\space")
("frame" "single")
("breaklines" "true"))))
:custom `(org-cite-global-bibliography . '(,(expand-file-name "~/MEGA/bibliography/references.bib")))
:hook (org-mode-hook . (lambda ()
(set (make-local-variable 'company-backends) '((company-dabbrev company-yasnippet)))))
:bind (:evil-motion-state-map
:package evil
("SPC a" . org-agenda))
:config
(with-eval-after-load 'ox-latex
(add-to-list 'org-latex-classes '("ltjsarticle" "\\documentclass[11pt]{ltjsarticle}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
(org-babel-do-load-languages 'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(gnuplot . t)
(shell . t)
(scheme . t)
(julia-vterm . t)
(jupyter . t)))
(leaf org-contrib
:ensure t
:require ox-extra
:config
(ox-extras-activate '(ignore-headlines)))
(leaf ox-latex-subfigure
:el-get (ox-latex-subfigure
:url "https://github.com/KPCCoiL/ox-latex-subfigure.git"
:branch "center-subfigure")
:require t
:after org)
(leaf org-ref
:ensure t
:require t
:after org
:pre-setq (org-ref-completion-library . 'org-ref-ivy-cite)
:custom ((bibtex-completion-bibliography . '("~/Documents/bibliography/references.bib"))
(bibtex-completion-notes-path . "~/Documents/bibliography/bibliography-notes.org")
(bibtex-completion-library-path . '("~/Documents/bibliography/bibtex-pdfs")))))(leaf doc-view
:tag "builtin"
:custom ((doc-view-continuous . t))
:hook (doc-view-mode-hook . auto-revert-mode))(leaf pdf-tools
:ensure t
:require t
:custom (pdf-view-use-scaling . t)
:hook (pdf-view-mode-hook
. (lambda ()
(display-line-numbers-mode -1)
(auto-revert-mode -1)))
:config
(pdf-tools-install))(defun edit-config ()
"Edit Emacs.org."
(interactive)
(tab-bar-new-tab)
(find-file "~/dotfiles/Emacs.org"))On macOS, Emacs launched from, say, Dock, has default-directory /.
(when (equal default-directory "/")
(setf default-directory "~"))Nobody wants their init.el messed up.
(setf custom-file null-device)