;;; init.el --- my emacs configuration -*- lexical-binding: t; -*-
;; Todo:
;; - Look at completion-preview-mode
;; - Look at grep-use-headings
;; - Look at elpa-openwith
(add-to-list 'load-path (expand-file-name (concat user-emacs-directory "site-lisp")))
;; Give me stats on garbage collection and startup time
(setopt garbage-collection-messages t)
(add-hook 'emacs-startup-hook
#'(lambda ()
(message (format "Initialised in %s seconds with %s garbage collections." (emacs-init-time) gcs-done))))
;; Use the gcmh to collect garbage when i'm not using emacs
(use-package gcmh
:ensure t
:custom
(gcmh-mode t))
(setopt user-full-name "noa")
(setopt user-mail-address "noa@noa.pub")
;; Properly distinguish these chords from their ascii legacy
(define-key input-decode-map [?\C-m] [C-m])
;;; Packages
;; For a long time i used use-package to manage emacs package configuration. Over time, i decided it was a bit too magic for me. The syntax is quite different to everything else in the configuration, and most of the options i was using were fairly simple.
;; I had a very brief excursion into using ~package-vc-install~ to manage packages directly from source, but i found this was too fragile, especially without relying on use-package. For now, i've modified a little defun from acdw i used for that purpose to simply install packages using package.el.
(defun package-ensure (pkg)
(unless (package-installed-p pkg)
(package-install pkg)))
;; Installed packages
;;These are the packages i use that aren't packaged in the debian repositories:
;; - 0x0
;; - isearch-mb
;; - jinx
;; - org-modern
;; - ox-rss
;; - valign
;; sudo apt install elpa-aggressive-indent elpa-consult elpa-dired-du elpa-htmlize elpa-jabber elpa-marginalia elpa-markdown-mode elpa-nov elpa-orderless elpa-vertico elpa-visual-fill-column elpa-ebib elpa-vc-fossil
;;; Modern keybindings
;; A lot of people say that you get used to emacs keybindings over time, and this is true. But i find it hard to maintain two sets of keybindings in my head: those for emacs, and those for everything else. So i think that it's best to make emacs use the same bindings as everything else. For now, we do that with wakib mode.
(require 'wakib-keys)
(setopt wakib-keys t)
(with-eval-after-load 'wakib-keys
(add-hook 'after-change-major-mode-hook 'wakib-update-major-mode-map)
(add-hook 'menu-bar-update-hook 'wakib-update-minor-mode-maps)
;; Modifying other modules
;; When remap is used it exits isearch abruptly after first instance
;; Use explicit keybindings instead
(define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "C-S-f") 'isearch-repeat-backward)
(define-key isearch-mode-map (kbd "M-;") 'isearch-repeat-forward)
(define-key isearch-mode-map (kbd "M-:") 'isearch-repeat-backward)
(define-key isearch-mode-map (kbd "C-v") 'isearch-yank-kill)
(define-key isearch-mode-map (kbd "M-d") 'isearch-delete-char))
;;; Executing commands
;;I make my caps lock a menu key, so i can open the command palette with it:
(define-key context-menu-mode-map (kbd "