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:29:06 GMT Organization: AT&T Broadband Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <87n0o4ez7i.fsf@wesley.springies.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1037827996 517 80.91.224.249 (20 Nov 2002 21:33:16 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 20 Nov 2002 21:33:16 +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 18EcTB-000082-00 for ; Wed, 20 Nov 2002 22:33:14 +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 18EcRK-0003Yr-00; Wed, 20 Nov 2002 16:31:18 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 30 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: sccrnsc02 1037827746 12.228.27.239 (Wed, 20 Nov 2002 21:29:06 GMT) Original-NNTP-Posting-Date: Wed, 20 Nov 2002 21:29:06 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:107260 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:3815 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3815 Alan Shutko writes: >"Timur Aydin" writes: > >> In programming, very often a number of lines are killed, yanked to another >> location and are reindented according to the new location. > >Try this. No idea where i got it. Actually, looks like I got it >from http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=u66crixve.fsf%40sdm.de&rnum=1 > >;; automatically indenting yanked text if in programming-modes >(defadvice yank (after indent-region activate) > (if (member major-mode '(emacs-lisp-mode > c-mode c++-mode > tcl-mode sql-mode > perl-mode cperl-mode > java-mode jde-mode > LaTeX-mode TeX-mode)) > (let ((transient-mark-mode nil)) > (indent-region (region-beginning) (region-end) nil)))) > This is better than my solution --- it uses the fact that yank sets the point and mark around the yanked text, so you don't need the chicanery I used. I'm adding this to my .emacs right now. -- Mike Slass