;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Sanemacs version 0.3.3 ;;;;;; https://sanemacs.com ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; For performance(setqgc-cons-threshold100000000)(setqread-process-output-max(*10241024));; 1mb(add-hook'after-init-hook#'(lambda();; restore after startup(setqgc-cons-threshold800000)));;; 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")(setqgnutls-algorithm-priority"NORMAL:-VERS-TLS1.3"));;; Setup package.el(require'package)(setqpackage-enable-at-startupnil)(add-to-list'package-archives'("melpa"."https://melpa.org/packages/"))(unlesspackage--initialized(package-initialize));;; Setup use-package(unless(package-installed-p'use-package)(package-refresh-contents)(package-install'use-package))(eval-when-compile(require'use-package))(setquse-package-always-ensuret);;; Useful Defaults(setq-defaultcursor-type'bar); Line-style cursor similar to other text editors(setqinhibit-startup-screent); Disable startup screen(setqinitial-scratch-message""); Make *scratch* buffer blank(setq-defaultframe-title-format'("%b")); Make window title the buffer name(setqring-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-mode1); Show closing parens by default(setqlinum-format"%4d "); Line number format(delete-selection-mode1); Selected text will be overwritten when you start typing(global-auto-revert-modet); Auto-update buffer if file has changed on disk(use-packageundo-tree; Enable undo-tree, sane undo/redo behavior:init(global-undo-tree-mode):config(setq-defaultundo-tree-auto-save-historynil))(add-hook'before-save-hook'delete-trailing-whitespace); Delete trailing whitespace on save;; 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)(defunsanemacs/backward-kill-word()(interactive"*")(push-mark)(backward-word)(delete-region(point)(mark)));;; Keybindings(global-set-key[mouse-3]'mouse-popup-menubar-stuff); Gives right-click a context menu(global-set-key(kbd"C->")'indent-rigidly-right-to-tab-stop); Indent selection by one tab length(global-set-key(kbd"C-<")'indent-rigidly-left-to-tab-stop); De-indent selection by one tab length(global-set-key(kbd"M-DEL")'sanemacs/backward-kill-word); Kill word without copying it to your clipboard(global-set-key(kbd"C-DEL")'sanemacs/backward-kill-word); Kill word without copying it to your clipboard;;; Offload the custom-set-variables to a separate file;;; This keeps your init.el neater and you have the option;;; to gitignore your custom.el if you see fit.(setqcustom-file(expand-file-name"custom.el"user-emacs-directory))(unless(file-exists-pcustom-file)(write-region""nilcustom-file));;; Load custom file. Don't hide errors. Hide success message(loadcustom-filenilt);;; Put Emacs auto-save and backup files to /tmp/ or C:/Temp/(defconstemacs-tmp-dir(expand-file-name(format"emacs%d"(user-uid))temporary-file-directory))(setqbackup-by-copyingt; Avoid symlinksdelete-old-versionstkept-new-versions6kept-old-versions2version-controltauto-save-list-file-prefixemacs-tmp-dirauto-save-file-name-transforms`((".*",emacs-tmp-dirt)); Change autosave dir to tmpbackup-directory-alist`((".*".,emacs-tmp-dir)));;; Lockfiles unfortunately cause more pain than benefit(setqcreate-lockfilesnil);;; Load wheatgrass as the default theme if one is not loaded already(if(notcustom-enabled-themes)(load-theme'wheatgrasst))(defunreload-config()(interactive)(load-file(expand-file-name"init.el"user-emacs-directory)))