all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: yank-and-indent
Date: Wed, 20 Nov 2002 21:29:06 GMT	[thread overview]
Message-ID: <m3fztvdive.fsf@localhost.localdomain> (raw)
In-Reply-To: 87n0o4ez7i.fsf@wesley.springies.com

Alan Shutko <ats@acm.org> writes:

>"Timur Aydin" <asdfweasdf@diowekfsdf.dersdre> 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

  reply	other threads:[~2002-11-20 21:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-20 20:28 yank-and-indent Timur Aydin
2002-11-20 21:01 ` yank-and-indent Michael Slass
2002-11-20 21:43   ` yank-and-indent Arnaldo Mandel
2002-11-20 21:07 ` yank-and-indent Alan Shutko
2002-11-20 21:29   ` Michael Slass [this message]
2002-11-20 21:39   ` yank-and-indent Timur Aydin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fztvdive.fsf@localhost.localdomain \
    --to=miknrene@drizzle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.