From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Michael Slass Newsgroups: gmane.emacs.help Subject: Re: yank-and-indent Date: Wed, 20 Nov 2002 21:01:57 GMT Organization: AT&T Broadband Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1037826358 26244 80.91.224.249 (20 Nov 2002 21:05:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 20 Nov 2002 21:05:58 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18Ec2l-0006or-00 for ; Wed, 20 Nov 2002 22:05:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18Ec3D-0006xu-00; Wed, 20 Nov 2002 16:06:23 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 44 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-NNTP-Posting-Host: 12.228.27.239 Original-X-Complaints-To: abuse@attbi.com Original-X-Trace: sccrnsc03 1037826117 12.228.27.239 (Wed, 20 Nov 2002 21:01:57 GMT) Original-NNTP-Posting-Date: Wed, 20 Nov 2002 21:01:57 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:107257 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3812 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3812 "Timur Aydin" 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