One of the minor modes I use most frequently is pabbrev-mode, a mode used for predictive expansion of text. Pabbrev doesn’t use a dictionary; instead, it scavenges your open buffers to find word usage and statistics. This allows it to be useful in a lot more contexts than just text editing: For example, it will offer completions of variable names if you have a buffer containing those names open.
Pabbrev overwrites the tab key, but if there is no valid expansion, then the behaviour falls through to the previously-bound command. This brings tab-completion to your ordinary text editor, which is just incredibly useful. The way pabbrev is implemented offers the suggested expansion as you are typing, so that you know whether or not you should expand your suggestion.
One annoying thing about the default behaviour is that if there are multiple suggestions for expansion, it will open for you to choose one. I prefer to just expand to the displayed expansion, always, without opening any additional buffers. To get this behaviour, redefine the following function
(defun pabbrev-expand-maybe-no-buffer()
"Expand abbreviation, or run previous command.
If there is no expansion the command returned by
`pabbrev-get-previous-binding' will be run instead."
(interactive)
(if pabbrev-expansion
(pabbrev-expand)
(let ((prev-binding
(pabbrev-get-previous-binding)))
(if (and (fboundp prev-binding)
(not (eq prev-binding 'pabbrev-expand-maybe)))
(funcall prev-binding)))))
To enable pabbrev-mode, first download it from here. Then, add the following lines to your .emacs file:
(require 'pabbrev ) (global-pabbrev-mode) (setq pabbrev-read-only-error nil)
Once this is done, pabbrev-mode will be enabled in all buffers that are not read-only. I highly recommend either it or another predictive-expansion mode; there are a few out there, but I haven’t tried them out.
HOLY SMOKES PABBREV MODE IS AMAZING!!!!!! Thank you for turning me on to this!
[...] but blogged about before restarting my .emacs file: pabbrev and cua. The links for those posts are here and here respectively. Pabbrev is a mode for predictive expansion, which is incredibly useful. Cua [...]