[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yank-and-indent
From: |
Michael Slass |
Subject: |
Re: yank-and-indent |
Date: |
Wed, 20 Nov 2002 21:01:57 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
"Timur Aydin" <asdfweasdf@diowekfsdf.dersdre> writes:
>Hi,
>
>In programming, very often a number of lines are killed, yanked to another
>location and are reindented according to the new location. Currently, the
>following sequence has to be done manually:
>
>1) Mark the lines to be killed
>2) Kill the lines
>3) Yank into new location
>4) Mark the same lines again.
>5) Hit C-M-\ to indent the lines according to new location.
>
>I would like to reduce the procedure to:
>
>1) Mark the lines to be killed
>2) Kill the lines
>3) Hit ???? to yank and indent the lines.
>
>Any wisdom on how this can be accomplished? I am a beginner in lisp, so
>hopefully there is a way that doesn't require writing a lisp function...
>
>--
>Timur
>
>
Try this:
(defun yank-and-indent ()
"Yank and indent yanked material according to mode."
(interactive)
(save-restriction
(narrow-to-region (point) (point))
(yank)
(let ((beg (point-min))
(end (point-max)))
(widen)
(indent-region beg end nil))))
--
Mike Slass