Skip to content

Instantly share code, notes, and snippets.

@ericchansen
Last active April 15, 2026 03:36
Show Gist options
  • Select an option

  • Save ericchansen/4fd9b4500e9abf8261fc085355850d57 to your computer and use it in GitHub Desktop.

Select an option

Save ericchansen/4fd9b4500e9abf8261fc085355850d57 to your computer and use it in GitHub Desktop.
My .emacs configuration
;;; .emacs --- Personal Emacs configuration -*- lexical-binding: t; -*-
;; Opinionated defaults: no tabs, visible whitespace, centralized backups,
;; and a handy C-c c binding to toggle comments on region or line.
;; Highlights dumb stuff.
(require 'whitespace)
(setq whitespace-style '(face empty tabs lines-tail trailing))
(global-whitespace-mode t)
;; 80 column marker.
(
add-hook 'rust-mode-hook (
lambda ()
(setq-local whitespace-line-column 80)
)
)
;; No tabs! Ever!
(setq-default indent-tabs-mode nil)
;; Save all backups to ~/.emacs_backups.
(setq make-backup-files t)
(
setq backup-directory-alist (
quote (
(\".\" . \"~/.emacs_backups\")
)
)
)
(setq backup-by-copying t)
(
setq delete-old-versions t
kept-new-versions 2
kept-old-versions 2
version-control t
)
;; Show current line and column numbers in the mode line.
(line-number-mode 1)
(column-number-mode 1)
;; Comment binding.
;; Hit Ctrl + C, C to comment or uncomment the selected region. If no region is
;; selected, it will comment/uncomment the current line.
(
defun comment-or-uncomment-region-or-line ()
\"Comments or uncomments the region or the current line if there's no active region\"
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position))
)
(comment-or-uncomment-region beg end)
)
)
(global-set-key (kbd \"C-c c\") 'comment-or-uncomment-region-or-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment