[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A little lisp help
From: |
Peter Lee |
Subject: |
Re: A little lisp help |
Date: |
Tue, 21 Jan 2003 22:34:38 GMT |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 |
Peter Lee <spam@nospam.org> writes:
> It works great when I mark a region and type: M-x curly-brace-region.
> However, it doesn't work the same way when I M-]. In this case the
> first curly brace is never inserted and the formatting is way off.
> Anyone know why they would behave differently ?
I've solved my problem, the docs advocated using forward-line with
negative arg vs. previous-line from a lisp program. When I changed
that it started working correctly when bound to a key.
(defun curly-brace-region (m p)
"Inserts curly braces around region and indents"
(interactive "r")
(if mark-active
(let ((transient-mark-mode nil))
(kill-region m p)
(insert-string "{")
(newline-and-indent)
(insert-string "}")
(newline-and-indent)
(forward-line -1)
(yank 1)
(forward-line 1)
(indent-region (- m 1) (point) nil))))
Thanks for the help.