My Emacs Setup, pt 5 Sanity
Published 2013-06-22 @ 12:00
Tagged emacs
Emacs is infinitely tweakable and you come to depend on some of those tweaks. But us rubyists are social creatures and we like to pair. What to do? Well, that’s why I have sanity.el. This is the minimal amount of tweaking I need to stay sane:
sanity.el:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
(require 'bs) (global-set-key (kbd "C-x C-b") 'bs-show) (global-set-key (kbd "M-s") 'fixup-whitespace) ; best function ever (when window-system (global-unset-key "\C-z")) ; ugh ;;;###autoload (defun rwd-previous-line-6 () ; C-up 6 lines at a time, ala xemacs (interactive) (previous-line 6)) ;;;###autoload (defun rwd-forward-line-6 () ; C-down 6 lines at a time, ala xemacs (interactive) (forward-line 6)) ;;;###autoload (defun rwd-scroll-up () ; M-up moves text but not cursor (interactive) (scroll-down 1)) ;;;###autoload (defun rwd-scroll-down () ; M-down moves text but not cursor (interactive) (scroll-up 1)) ;; compatibility: (global-set-key (kbd "M-g") 'goto-line) (global-set-key (kbd "<C-up>") 'rwd-previous-line-6) (global-set-key (kbd "<C-down>") 'rwd-forward-line-6) (global-set-key (kbd "<M-up>") 'rwd-scroll-up) (global-set-key (kbd "<M-down>") 'rwd-scroll-down) |
Without these, I’m crippled.
Windows:
I run full-screen emacs almost always and utilize split windows for everything.
Emacs provides some keys to cycle through the splits but that gets
cumbersome really fast. winner-number
to the rescue. It is
fantastic. It allows you to mentally number all of the windows and
switch to them immediately. I set window-number-meta-mode
but if you
like to use M-<number>
instead of C-u <number>
then you want the
regular mode.
rwd-windows.el:
1 2 3 4 5 |
;;;###autoload (progn (winner-mode 1) (require 'window-number) (window-number-meta-mode 1)) |
winner-mode
provides window history so if you collapse down to one
window going back to you N-way split is as easy as C-c <left>
.
Collapsing back down is as easy as C-c <right>
(or whatever you want
to bind them to).
Bell
I set '(visible-bell t)
in my customize which turns off an audible
bell. Unfortunately, on OSX that means I get to see a black 200x200
square flash in the middle of the window every time I hit C-g
. It is
ugly, distracting, bad UX, and the maintainer of the OSX side of emacs
doesn’t give a damn (about much of anything it seems).
Luckily, it is really easy to fix. This code makes the modeline flash black instead.
rwd-bell.el:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
;; found at http://www.elliotglaysher.org/emacs/ ;; ----------------------------------------------------------------------- ;; Prevent the bell from ringing all the time. ;; ----------------------------------------------------------------------- ;; nice little alternative visual bell; Miles Bader <miles /at/ gnu.org> ;; TODO(erg): Figure out why that note doesn't appear in the mode-line-bar... (defcustom mode-line-bell-string "ding" ; "♪" "Message displayed in mode-line by `mode-line-bell' function." :group 'user) (defcustom mode-line-bell-delay 0.1 "Number of seconds `mode-line-bell' displays its message." :group 'user) ;; internal variables (defvar mode-line-bell-cached-string nil) (defvar mode-line-bell-propertized-string nil) ;;;###autoload (defun mode-line-bell () "Briefly display a highlighted message in the mode-line. The string displayed is the value of `mode-line-bell-string', with a red background; the background highlighting extends to the right margin. The string is displayed for `mode-line-bell-delay' seconds. This function is intended to be used as a value of `ring-bell-function'." (unless (equal mode-line-bell-string mode-line-bell-cached-string) (setq mode-line-bell-propertized-string (propertize (concat (propertize "x" 'display `(space :align-to (- right ,(string-width mode-line-bell-string)))) mode-line-bell-string) 'face '(:background "black"))) (setq mode-line-bell-cached-string mode-line-bell-string)) (message mode-line-bell-propertized-string) (sit-for mode-line-bell-delay) (message "")) ;;;###autoload (setq ring-bell-function 'mode-line-bell) |