General Emacs Configurations
Emacs Server
This sets it up such that, when C-x k
is pressed, an active
emacsclient session will be closed. First, it clones any active
local keymaps if they exist.
(add-hook 'server-switch-hook (lambda () (when (current-local-map) (use-local-map (copy-keymap (current-local-map)))) (when server-buffer-clients (local-set-key (kbd "C-x k") 'server-edit))))
Start the emacs server, if it isn't running already.
(if (and (fboundp 'server-running-p) (not (server-running-p))) (server-start))
Abbrev-Mode
(setq abbrev-file-name "~/.emacs.d/abbrev_defs") (setq save-abbrevs t) (setq abbrev-mode t)
Tabs?!
(setq tab-width 2)
Change "yes or no" to "y or n"
(fset 'yes-or-no-p 'y-or-n-p)
UI
Set native vs non-native fullscreen on the Mac:
;; (setq ns-use-native-fullscreen nil) (setq ns-use-native-fullscreen t)
Be less aggressive when vertically splitting my windows: (default 80)
(setq split-height-threshold 110)
Minimum height for splitting windows sensibly. If this is an integer, ‘split-window-sensibly’ may split a window vertically only if it has at least this many lines.
UTF-8
(prefer-coding-system 'utf-8) (when (display-graphic-p) (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
Save Hooks
I don't like it when delete-trailing-whitespace
moves my cursor
around when it finds I'm sitting on some white-space. It just ends
up kicking back my indentation for something I was just about to
start typing.
(defun toby/delete-trailing-whitespace () "Ignore current line when deleting trailing whitespace" (interactive) (let ((first-part-start (point-min)) (first-part-end (point-at-bol)) (second-part-start (point-at-eol)) (second-part-end (point-max))) (delete-trailing-whitespace first-part-start first-part-end) (delete-trailing-whitespace second-part-start second-part-end)))
Clean-up trailing white-space on save.
(add-hook 'before-save-hook 'toby/delete-trailing-whitespace)
Dired Mode
Set ls
flags and load some dired extensions.
(setq dired-listing-switches "-alh") (require 'dired-x) (require-package 'dired+) (require 'dired+)
Kill-Ring
(require-package 'browse-kill-ring) (browse-kill-ring-default-keybindings)
iSearch
(require-package 'ag) (require-package 'isearch+) (eval-after-load "isearch" '(require 'isearch+))
ADOPTED Multiple Cursors
- State "ADOPTED" from "REJECTED"
(require-package 'multiple-cursors) (autoload 'mc/edit-lines "multiple-cursors" "Multiple Cursors" t) (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) (autoload 'mc/mark-next-like-this "multiple-cursors" "Multiple Cursors" t) (autoload 'mc/mark-previous-like-this "multiple-cursors" "Multiple Cursors" t) (autoload 'mc/mark-all-like-this "multiple-cursors" "Multiple Cursors" t) (global-set-key (kbd "C->") 'mc/mark-next-like-this) (global-set-key (kbd "C-<") 'mc/mark-previous-like-this) (global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
ADOPTED Which-Key Mode
- State "ADOPTED" from "REJECTED"
- State "REJECTED" from "EXPERIMENTAL"
- State "EXPERIMENTAL" from
(require-package 'which-key) (which-key-mode)
Configuration
(defun toby/reload-config () "Reload ~/.emacs.d/init.el" (interactive) (load-file (concat user-emacs-directory "init.el"))) (global-set-key (kbd "C-x x r") 'toby/reload-config)
(provide 'emacs-init)