;;; For performance (setq gc-cons-threshold 100000000) (setq read-process-output-max (* 1024 1024)) ;; 1mb (add-hook 'after-init-hook #'(lambda () ;; restore after startup (setq gc-cons-threshold 800000))) ;;; Disable menu-bar, tool-bar, and scroll-bar. (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;;; Fix this bug: ;;; https://www.reddit.com/r/emacs/comments/cueoug/the_failed_to_download_gnu_archive_is_a_pretty/ (when (version< emacs-version "26.3") (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")) (setq-default cursor-type 'bar) ; Line-style cursor similar to other text editors (setq inhibit-startup-screen t) ; Disable startup screen (setq initial-scratch-message "") ; Make *scratch* buffer blank (setq-default frame-title-format '("%b")) ; Make window title the buffer name (setq ring-bell-function 'ignore) ; Disable bell sound (fset 'yes-or-no-p 'y-or-n-p) ; y-or-n-p makes answering questions faster (show-paren-mode 1) ; Show closing parens by default (setq linum-format "%4d ") ; Line number format (delete-selection-mode 1) ; Selected text will be overwritten when you start typing (global-auto-revert-mode t) ; Auto-update buffer if file has changed on disk ;; Show line numbers in programming modes (add-hook 'prog-mode-hook (if (or ; If linum-mode doesn't exist... (not (fboundp 'linum-mode)) ; ...or Emacs has display-line-numbers-mode capability (and (fboundp 'display-line-numbers-mode) (display-graphic-p))) ; ...then use display-line-numbers-mode! 'display-line-numbers-mode ; Otherwise, use linum-mode 'linum-mode)) (global-display-line-numbers-mode) ;; Define the whitespace style. (setq-default whitespace-style '(face spaces empty tabs newline trailing space-mark tab-mark newline-mark)) ;; Whitespace color corrections. (require 'color) (let* ((ws-lighten 30) ;; Amount in percentage to lighten up black. (ws-color (color-lighten-name "#000000" ws-lighten))) (custom-set-faces `(whitespace-newline ((t (:foreground ,ws-color)))) `(whitespace-missing-newline-at-eof ((t (:foreground ,ws-color)))) `(whitespace-space ((t (:foreground ,ws-color)))) `(whitespace-space-after-tab ((t (:foreground ,ws-color)))) `(whitespace-space-before-tab ((t (:foreground ,ws-color)))) `(whitespace-tab ((t (:foreground ,ws-color)))) `(whitespace-trailing ((t (:foreground ,ws-color)))))) ;; Make these characters represent whitespace. (setq-default whitespace-display-mappings '( (space-mark 32 [183] [46]) (newline-mark ?\n [172 ?\n] [36 ?\n]) (newline-mark ?\r [182] [35]) (tab-mark ?\t [187 ?\t] [62 ?\t]))) ;; Don't enable whitespace for. (setq-default whitespace-global-modes '(not shell-mode help-mode magit-mode magit-diff-mode ibuffer-mode dired-mode occur-mode)) ;; Set whitespace actions. (setq-default whitespace-action '(cleanup auto-cleanup)) ;;; Put Emacs auto-save and backup files to /tmp/ or C:/Temp/ (defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) (setq backup-by-copying t ; Avoid symlinks delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t auto-save-list-file-prefix emacs-tmp-dir auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t)) ; Change autosave dir to tmp backup-directory-alist `((".*" . ,emacs-tmp-dir))) ;;; Lockfiles unfortunately cause more pain than benefit (setq create-lockfiles nil) ;;; Load wheatgrass as the default theme if one is not loaded already (if (not custom-enabled-themes) (load-theme 'wheatgrass t)) (defun reload-config () (interactive) (load-file (expand-file-name "init.el" user-emacs-directory))) ;; Make a single ESC quit the current action (global-set-key (kbd "" 'keyboard-escape-quit)) (add-hook 'prog-mode-hook (lambda () (electric-pair-local-mode))) ;; Org mode config (setq-default org-startup-indented t)