help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Customising fill-paragrah


From: Iain Dalton
Subject: Re: Customising fill-paragrah
Date: Fri, 13 Feb 2009 19:32:41 -0700

> it'll take maybe 20 to 30 min to write it.

I'd expect it to be easier.  Here's my version, which took me 10
minutes, and that's because I've never written an elisp function
before and didn't know fill-paragraph and move-b-o-l need args.  It
goes something like this:

(defun colon-list-fill-paragraph ()
 (interactive)
 (backward-paragraph)
 (forward-line)
 (fill-paragraph nil)
 (next-line)
 (insert "    ")
 (fill-paragraph nil)
 (move-beginning-of-line 1)
 (previous-line)
 (forward-char)
 (insert "  "))

The only problem with this hastily hacked function is that your first
line may be two chars too long.  You could improve it with Chetan's
idea of replacing your paragraph's first char with space, doing what
you need to do, then replacing with a colon.

Remember, functions do exactly what you can do with the keyboard.  You
can write one by doing what you want your function to do by hand,
recording your keystrokes, learning the functions your keystrokes
invoke (C-h c), and writing them into the function body.

For that matter, consult the Emacs manual on Keyboard Macros, and you
can write a function without knowing Emacs Lisp.  Unfortunately you
may not understand your resulting function because it looks like a
string of numbers.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]