On Line Wrapping in Emacs 23(pre)

Emacs, my editor of choice, is currently in pre-test; the next version, 23, will feature unicode, anti-aliased fonts and many other goodies.  It will also feature soft (visual) line wrapping and the attendant redefinition of next-line and previous-line commands for moving by lines-as-seen-on-screen instead of lines-as-contained-in-the-file.  This is very good for text modes and proportional fonts, but breaks programming modes, editing tabular data and keyboard macros.

Normally, functionality like this is implemented as a minor mode (viz. show-paren-mode, transient-mark-mode, font-lock, …), but cursor movement by visual line is a global setting instead, causing no end of discussions on the emacs mailing list.  The maintainers’ current stance seems to be “we’re in pre-test, so can only accept bug fixes for regressions from emacs 22, and this was already discussed 6 months ago.”

Luckily, emacs is quite customizable, so I implemented the behavior I want: visual line mode (soft word-wrapped lines) and visual line movement (cursor moves down one visual line instead of one text-file line) for text modes, and the normal behavior in all other modes.

(setq line-move-visual nil)
(add-hook 'text-mode-hook 'turn-on-visual-line-mode)
(add-hook 'text-mode-hook
          (lambda () (set (make-local-variable 'line-move-visual) t)))

Tags:

Leave a Reply