nixconfig/emacs/init.org
2023-11-27 15:30:15 +01:00

3.4 KiB

Emacs Init File

Initialization

Requirements

Since I am using cl-defun in this init file, I need to import cl-macs.

  (require 'cl-macs)

Personal Information

Name Mail
Daniel Ziltener dziltener@lyrion.ch
  (let ((row (car input)))
    (setq user-full-name (cl-first row))
    (setq user-mail-address (cl-second row)))

For storage of passwords, I use 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.

  (setq custom-file "~/.emacs.d/custom.el")
  (when (file-exists-p custom-file)
    (load custom-file))

Package Manager

I use straight.el as package manager.

Setting Value
Use Straight as default f
    (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))))

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.

  (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))))

Core Emacs Customization   important

(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))