Showing posts with label Emacs. Show all posts
Showing posts with label Emacs. Show all posts

Saturday, August 9, 2008

Emacs Word Wrap

Real word wrapping in emacs isn't automatic, but here's how it can be done. I found these instructions at http://lispy.wordpress.com/2007/07/12/dark-secrets-of-emacs-word-wrapping/. It's not perfect; despite the comments on that website, I don't yet know how to make word-wrap work after vertical splitting. First, get longlines.el and put it somewhere. Then, add the following lines to your .emacs:

(load "/path/to/longlines.el" t t)
(autoload 'longlines-mode "longlines.el" "Minor mode for editing long lines." t)
;; Uncomment the next line to wrap by default in text mode
;;(add-hook 'text-mode-hook 'longlines-mode)

To activate manually, do M-x longlines. More info at http://www.emacswiki.org/cgi-bin/wiki/LongLines.

Adding An Emacs Menu

Here's some template code for adding a menu item to the main emacs menu bar. I don't know hos this works; I just use it as a template!

;;;;;;; Add items to menu bar
(modify-frame-parameters (selected-frame) '((menu-bar-lines . 2)))
;; Make a menu keymap (with a prompt string)
;; and make it the menu bar item's definition.
(define-key global-map [menu-bar MyMenu] (cons "MyMenu" (make-sparse-keymap "MyMenu")))
;; Define specific subcommands in this menu.
(defun MyMenu-linkify() (interactive) (replace-regexp "^\\(.*\\)$" "\\1
"))
(define-key global-map
[menu-bar MyMenu linkify]
'("Linkify" . MyMenu-linkify))
(define-key global-map
[menu-bar MyMenu truncate]
'("Truncate em" . toggle-truncate-lines))