113 lines
3.4 KiB
Org Mode
113 lines
3.4 KiB
Org Mode
#+TITLE: Emacs Init File
|
|
#+AUTHOR: Daniel Ziltener
|
|
|
|
* Initialization
|
|
|
|
** Requirements
|
|
|
|
Since I am using ~cl-defun~ in this init file, I need to import ~cl-macs~.
|
|
|
|
#+begin_src emacs-lisp
|
|
(require 'cl-macs)
|
|
#+end_src
|
|
|
|
** Personal Information
|
|
|
|
#+NAME: pers-info-table
|
|
| Name | Mail |
|
|
|-----------------+---------------------|
|
|
| Daniel Ziltener | dziltener@lyrion.ch |
|
|
|
|
#+begin_src emacs-lisp :var input=pers-info-table
|
|
(let ((row (car input)))
|
|
(setq user-full-name (cl-first row))
|
|
(setq user-mail-address (cl-second row)))
|
|
#+end_src
|
|
|
|
For storage of passwords, I use [[https://www.passwordstore.org/][pass]]: src_emacs-lisp[]{(auth-source-pass-enable)}
|
|
|
|
** Customizations
|
|
|
|
Since this init file is version controlled, and I set all customizations
|
|
myself in =use-package= blocks, I want Emacs to use a separate file
|
|
for authorized =.dir-local= variables and similar stuff.
|
|
|
|
#+begin_src emacs-lisp
|
|
(setq custom-file "~/.emacs.d/custom.el")
|
|
(when (file-exists-p custom-file)
|
|
(load custom-file))
|
|
#+end_src
|
|
|
|
** Package Manager
|
|
|
|
I use =straight.el= as package manager.
|
|
|
|
#+NAME: straight-settings
|
|
| Setting | Value |
|
|
|-------------------------+-------|
|
|
| Use Straight as default | f |
|
|
|
|
#+begin_src emacs-lisp :var tbl=straight-settings
|
|
(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))
|
|
|
|
(let ((settings (car tbl)))
|
|
(setq straight-use-package-by-default
|
|
(string= "t" (cl-first settings))))
|
|
#+end_src
|
|
|
|
* Helper Functions
|
|
|
|
Those are meant to reduce code duplication, and add some basic useful features.
|
|
The first one is a function to create conditional keybindings.
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
(cl-defun conditional-keybind
|
|
"Creates a keybinding that checks `filter-fn`. If it succeeds,
|
|
`target-fn` is run, otherwise `fail-fn`. If no fail-fn is given,
|
|
`self-insert-command` is run instead.
|
|
`target-fn` and `fail-fn` must both be interactive."
|
|
(lambda (_prefix)
|
|
(interactive "P")
|
|
(if (funcall filter-fn)
|
|
(call-interactively target-fn)
|
|
(call-interactively fail-fn))))
|
|
#+end_src
|
|
|
|
* Core Emacs Customization :important:
|
|
|
|
#+begin_src emacs-lisp
|
|
(use-package emacs
|
|
:delight (eldoc-mode " ")
|
|
:custom
|
|
(completion-cycle-threshold 10)
|
|
(display-time-mode t)
|
|
(enable-recursive-minibuffers t)
|
|
(enable-remote-dir-locals t)
|
|
(global-hl-line-mode t)
|
|
(indent-tabs-mode nil)
|
|
(menu-bar-mode nil)
|
|
(minibuffer-prompt-properties (read-only t cursor-intangible t face minibuffer-prompt))
|
|
(read-extended-command-predicate #'command-completion-default-include-p)
|
|
(recentf-mode t)
|
|
(scroll-bar-mode nil)
|
|
(tab-always-indent 'complete)
|
|
(tool-bar-mode nil)
|
|
:custom-face
|
|
(default ((t (:weight bold :height 113 :width normal :family "VictorMono Nerd Font"))))
|
|
:hook
|
|
(minibuffer-setup . cursor-intangible-mode)
|
|
:config
|
|
(advice-add 'risky-local-variable-p :override #'ignore))
|
|
#+end_src
|
|
|