[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 21:52:52 GMT |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 |
Ok this is what I have so far.
(defun curly-brace-region (m p)
"Inserts curly braces around region and indents"
(interactive "r")
;; (message "mark=%d, point=%d" m p)
(kill-region m p)
(insert-string "{")
(newline-and-indent)
(insert-string "}")
(newline-and-indent)
(previous-line 2)
(newline-and-indent)
(yank 1)
(kill-line)
(next-line 1)
(indent-region (- m 1) (point) nil))
(global-set-key "\M-]" 'curly-brace-region)
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 ?
Thanks.