I haven’t written about recent additions I’ve made to my emacs configuration, so I’ll go through a number of them here. These are all passive minor modes; once you set them up, they work automatically. You don’t have to remember any keybindings to use them, or activate them in a buffer; they just work.
Mic-Paren
mic-paren is a package that enhances emacs’ parenthesis highlighting. It recognizes escaped parentheses, as well as matching parentheses both in front and back of point. It also has other options, such as highlighting other delimiters and the containing s-expressions. You’ll have to download this from http://www.emacswiki.org/emacs/download/mic-paren.el and then activate it with:
(require 'mic-paren) (paren-activate)
Pager
Pager is a library for fixing emac’s paging. Without it, doing a page down followed by a page up has no guarantee of moving point back to it’s original location. Download pager from wget http://user.it.uu.se/~mic/pager.el and activate it with:
(require 'pager) (global-set-key "\C-v" 'pager-page-down) (global-set-key [next] 'pager-page-down) (global-set-key "\ev" 'pager-page-up) (global-set-key [prior] 'pager-page-up) (global-set-key '[M-up] 'pager-row-up) (global-set-key '[M-kp-8] 'pager-row-up) (global-set-key '[M-down] 'pager-row-down) (global-set-key '[M-kp-2] 'pager-row-down)
which-func
Which-func is a minor-mode that will add the function point is inside to the mode-line. This is mainly useful if you are looking at large functions, but it could also be nice if you use vertical splits. Which-func mode is built into emacs, so you have to go through very little work to enable it.
(setq which-func-modes t) (which-func-mode 1)
winpoint
Winpoint is a package that enhances multiple-window viewing of a file. Normally, if you have two windows open to the same buffer at different locations, and temporarily use one window to view something else, when you return to the original buffer it will have point be located where the other window’s point is. This is usually not the behavior I want, and winpoint fixes this so that point is kept on a per-window basis. To get this, you must first put winpoint.el, available from wget http://www.emacswiki.org/emacs/download/winpoint.el, in your .emacs.d directory, and then add the following to your .emacs file:
(require 'winpoint) (winpoint-mode t)
dired-isearch
This package will replace the regular isearch commands with commands that will only match filenames when in dired-mode. This is normally what I want to do, so this package just makes it slightly easier. It is available from http://emacswiki.wikiwikiweb.de/cgi-bin/wiki/download/dired-isearch.el, with the following required in your .emacs file:
(require 'dired-isearch) (define-key dired-mode-map (kbd "C-s") 'dired-isearch-forward) (define-key dired-mode-map (kbd "C-r") 'dired-isearch-backward) (define-key dired-mode-map (kbd "ESC C-s") 'dired-isearch-forward-regexp) (define-key dired-mode-map (kbd "ESC C-r") 'dired-isearch-backward-regexp)
highlight-parentheses
The last package I’ll cover today is for highlighting parentheses around the current point, not just ones matching the current point. This is useful for telling you when the containing expression starts or ends, for example. This requires a bit more customizations than the other ones, for two reasons:
- It does not define a global mode, so you have to do this yourself.
- The default colors I find are pretty terrible.
Given that, my customizations are as follows:
(require 'highlight-parentheses) (defun turn-on-highlight-parentheses-mode () (highlight-parentheses-mode t)) (define-global-minor-mode global-highlight-parentheses-mode highlight-parentheses-mode turn-on-highlight-parentheses-mode) (global-highlight-parentheses-mode) (setq hl-paren-background-colors '("green"))
The “green” is just what I am using now; change that to whatever color you wish.