Skip to content

Instantly share code, notes, and snippets.

Last active November 29, 2023 00:12
Show Gist options
  • Save mgmarlow/c298502c0f84d1c06c881b8de404b7c7 to your computer and use it in GitHub Desktop.
Save mgmarlow/c298502c0f84d1c06c881b8de404b7c7 to your computer and use it in GitHub Desktop.
Emacs 29 better defaults
;;;; Better defaults for Emacs to help get new users up and running quickly.
;;;; This configuration is meant to help solve some common usability problems,
;;;; particularly with Emacs's default completion framework, cluttered UI,
;;;; and package installation. Inspired by the Better Defaults repo:
;;;; Annotations are included for various options, but I recommend using
;;;; the built-in Emacs help to learn more about each configuration setting.
;;;; For example, `C-h v` or `M-x describe-variable`.
;; Performance tweaking
(setq gc-cons-threshold 100000000) ; 100 mb
(setq read-process-output-max (* 1024 1024)) ; 1mb
;; Remove UI clutter
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq inhibit-startup-screen t)
;; Set your font preferences here
(set-face-attribute 'default nil :height 120)
;; On OSX swap meta and super for better keyboard ergonomics. This is
;; great if you use a Windows-style keyboard on Mac OS.
(defmacro if-osx (&rest body)
`(if (eq system-type 'darwin)
(progn ,@body)))
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super))
;; Unique buffer names for matching files, very useful when dealing
;; with lots of index.ts, for example
(require 'uniquify)
;; Misc. settings
;; Use `C-h v` to read the docs on the individual options
(electric-pair-mode t)
(show-paren-mode 1)
(setq-default indent-tabs-mode nil)
(save-place-mode t)
(savehist-mode t)
(recentf-mode t)
(global-auto-revert-mode t)
;; Display line numbers when in programming modes
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(setq uniquify-buffer-name-style 'forward
window-resize-pixelwise t
frame-resize-pixelwise t
load-prefer-newer t
backup-by-copying t
custom-file (expand-file-name "custom.el" user-emacs-directory))
(unless package-archive-contents
;; Great looking theme
(use-package modus-themes
:ensure t
;; Code-completion at point
(use-package company
:ensure t
:hook (after-init . global-company-mode)
(company-idle-delay 0))
;; Better minibuffer completions and project searching
(use-package vertico
:ensure t
(vertico-cycle t)
(read-buffer-completion-ignore-case t)
(read-file-name-completion-ignore-case t)
(completion-styles '(basic substring partial-completion flex))
(use-package savehist
(use-package marginalia
:after vertico
:ensure t
;; Use emacsclient to open files in an already-running Emacs process
(require 'server)
(unless (server-running-p) (server-start))
Copy link

mgmarlow commented Nov 10, 2022

How to install Emacs (with native compilation)

Install via

brew tap d12frosted/emacs-plus
brew install emacs-plus@29 --with-native-comp

Then, create ~/.emacs.d/ and drop this init.el file into that directory:

mkdir ~/.emacs.d/
curl -o ~/.emacs.d/init.el

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment