;; ---------------------------------------------------------------------------- ;; Improve start-up time by tweaking the garbage collector settings. ;; Reference: ;; - https://emacs.stackexchange.com/a/34367 (defvar gc-cons-threshold-original gc-cons-threshold) (setq gc-cons-threshold (* 1024 1024 50)) (defvar file-name-handler-alist-original file-name-handler-alist) (setq file-name-handler-alist nil) (run-with-idle-timer 5 nil (lambda () (setq gc-cons-threshold gc-cons-threshold-original) (setq file-name-handler-alist file-name-handler-alist-original) (makunbound 'gc-cons-threshold-original) (makunbound 'file-name-handler-alist-original) (message "gc-cons-threshold and file-name-handler-alist restored"))) ;; ---------------------------------------------------------------------------- ;; Uncomment this to enable statistics. Once Emacs is ready, you can ;; use the `use-package-report' to gather data on startup timing. ;; (setq use-package-compute-statistics t) ;; ---------------------------------------------------------------------------- ;; Bootstrap straight.el per README instructions ;; Reference: ;; - https://github.com/raxod502/straight.el (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) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) ;; ---------------------------------------------------------------------------- ;; Install and configure use-package ;; Reference: ;; - https://github.com/nasseralkmim/.emacs.d/blob/master/init.el (straight-use-package 'use-package) (setq use-package-verbose nil use-package-compute-statistics t use-package-expand-minimally t use-package-always-defer t) (setq straight-use-package-by-default t) ;; ---------------------------------------------------------------------------- ;; Control minor-mode indication in the mode-line ;; Useful to prevent minor mode to clutter the modline. (use-package diminish :demand) ;; ---------------------------------------------------------------------------- ;; Minimizes GC interferecen with user activity (use-package gcmh :diminish gcmh-mode :init (setq gcmh-idle-delay 0.5 gcmh-high-cons-threshold (* 16 1024 1024)) (gcmh-mode 1)) ;; ---------------------------------------------------------------------------- ;; better default (use-package emacs :hook ((before-save . delete-trailing-whitespace)) :init ;; Backup and auto-save in /tmp. (setq backup-directory-alist `((".*" . ,temporary-file-directory))) (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t))) ;; Use space instead of tabs. (setq-default indent-tabs-mode nil) ;; Do not wait for highlighting search matches (setq lazy-highlight-initial-delay 0) ;; Zoom in and out using and (global-set-key (kbd "C-+") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) ;; UTF-8 encoding (prefer-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (set-keyboard-coding-system 'utf-8) ;; native-comp (setq native-comp-async-report-warnings-errors nil)) ;; ---------------------------------------------------------------------------- ;; Configure the UI look and feel (use-package +ui :straight nil :load-path "~/.emacs.d/core" :demand) ;; ---------------------------------------------------------------------------- (use-package +theme :straight nil :load-path "~/.emacs.d/core" :hook (after-init . load-theme-and-reset-ui) :demand) (use-package vertico ;; :straight (:files (:defaults "extensions/*")) :demand :custom (vertico-cycle t) :config (vertico-mode)) (use-package savehist :init (savehist-mode)) ;; Projectile (use-package projectile :demand :init (defun use-projectile-root () (if (and (projectile-project-p) (projectile-project-root)) (setq default-directory (projectile-project-root)))) :config (projectile-mode) :hook (find-file . use-projectile-root)) ;; Provide a backend for redo. ;; Will not be necessary once Emacs 28 is released (use-package undo-fu) ;; Interact with the clipboard (defun copy-to-clipboard () "Copy the selection to clipboard." (interactive) (if (display-graphic-p) (progn (message "Yanked region to x-clipboard!") (call-interactively 'clipboard-kill-ring-save) ) (if (region-active-p) (progn (shell-command-on-region (region-beginning) (region-end) "xsel -i -b") (message "Yanked region to clipboard!") (deactivate-mark)) (message "No region active; can't yank to clipboard!")))) (defun paste-from-clipboard () "Paste the clipboard content into the buffer at cursor." (interactive) (setq select-enable-clipboard t) (yank) (setq select-enable-clipboard nil)) (use-package +evil :straight nil :load-path "~/.emacs.d/core" :demand) (defvar-local menu-major-mode/body (lambda () (interactive) nil)) (defun set-menu-major-mode (m) (lambda () (setq-local menu-major-mode/body m))) ;; Source: http://www.emacswiki.org/emacs-en/download/misc-cmds.el (defun revert-buffer-no-confirm () "Revert buffer without confirmation." (interactive) (revert-buffer :ignore-auto :noconfirm)) (defun print-file-name () "Print the path of the current buffer." (interactive) (message (buffer-file-name))) ;; Hydra (use-package hydra :demand :after (+evil projectile +theme) :config (defhydra menu-program (:exit t :columns 4) ("e" eldoc-mode "Toggle eldoc") ("f" flycheck-mode "Toggle flycheck")) (+menu-themes) (defhydra menu-org-notes (:exit t :columns 4) "Organize your life in plain text (or so I’ve been told)" ("n" (org-capture nil "n") "Start working on a new task") ("i" (find-file org-default-notes-file) "Visit the inbox") ("ci" (org-capture nil "i") "Add an entry in the inbox") ("I" (find-file +org-idea-file) "Visit the ideas box") ("cI" (org-capture nil "I") "I have an idea") ("t" (find-file +org-today-file) "Visit today’s file") ("ct" (org-capture nil "t") "Add an entry in today’s file") ("y" (find-file +org-yesterday-file) "Visit yesterday’s file") ("a" org-agenda "Visit org agenda")) (defhydra menu-home (:exit t :columns 4) "Where everything start" ("." projectile-find-file "Find file") (":" execute-extended-command "M-x") ("b" switch-to-buffer "Switch to buffer") ("à" projectile-switch-project "Switch to project") ("p" menu-program/body "Program stuff") ("o" menu-org-notes/body "Org") ("t" menu-themes/body "Theming") ("m" (call-interactively menu-major-mode/body) "Major mode") ("x" kill-this-buffer "Kill buffer") ("q" delete-window "Delete window") ("c" comment-dwim "Toggle comment") ("s" stgit "Stacked Git") ("r" revert-buffer-no-confirm "Reload file") ("f" flyspell-buffer "Spellcheck")) :bind (:map evil-normal-state-map ("SPC" . menu-home/body) :map evil-insert-state-map ("M-SPC" . menu-home/body) :map evil-visual-state-map ("SPC" . menu-home/body))) (use-package +prog :straight nil :load-path "~/.emacs.d/core" :demand) (use-package +git :straight nil :load-path "~/.emacs.d/core" :demand) (use-package +ocaml :straight nil :after +prog :load-path "~/.emacs.d/lang" :demand) (use-package +coq :straight nil :after +prog :load-path "~/.emacs.d/lang" :demand) (use-package +elisp :straight nil :after +prog :load-path "~/.emacs.d/lang" :demand) (use-package +org :straight nil :after +prog :load-path "~/.emacs.d/lang" :demand) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(current-theme 'ancientless)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. )