From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: yank without indentation? Date: Fri, 06 Jun 2014 08:36:34 +0800 Message-ID: <877g4uvppp.fsf@ericabrahamsen.net> References: <87oay7v179.fsf@ericabrahamsen.net> <87wqcvz8pb.fsf@gmail.com> <87ppine5kn.fsf@geodiff-mac3.ulb.ac.be> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1402014820 31884 80.91.229.3 (6 Jun 2014 00:33:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Jun 2014 00:33:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 06 02:33:33 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wsi68-0008BM-03 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Jun 2014 02:33:32 +0200 Original-Received: from localhost ([::1]:44438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsi67-0007ll-Fp for geh-help-gnu-emacs@m.gmane.org; Thu, 05 Jun 2014 20:33:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48258) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsi5s-0007ld-5N for help-gnu-emacs@gnu.org; Thu, 05 Jun 2014 20:33:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wsi5m-00063S-Mo for help-gnu-emacs@gnu.org; Thu, 05 Jun 2014 20:33:16 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:33090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wsi5m-000635-GY for help-gnu-emacs@gnu.org; Thu, 05 Jun 2014 20:33:10 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Wsi5k-0007uW-6h for help-gnu-emacs@gnu.org; Fri, 06 Jun 2014 02:33:08 +0200 Original-Received: from 111.197.153.25 ([111.197.153.25]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Jun 2014 02:33:08 +0200 Original-Received: from eric by 111.197.153.25 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Jun 2014 02:33:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 111.197.153.25 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux) Cancel-Lock: sha1:59Qs6K3lWaAajnzLFw2dukkoKwg= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98046 Archived-At: Nicolas Richard writes: > Thorsten Jolitz writes: > >> Eric Abrahamsen writes: >> >>> Has anyone come up with a yank-without-indentation routine? Why am I >>> always killing multi-line text with enormous left-hand whitespace, and >>> wanting to yank it without that whitespace in place? Has anyone dealt >>> with this? >> >> I have 3 chomp function loaded right now: >> >> ,---------------- >> | org-babel-chomp >> | outshine-chomp >> | s-chomp >> `---------------- >> >> and outshine-chomp seems to be the only one that handles leading >> whitespace to. > > That's because removing both leading and trailing whitespace is usually > called trim :) > So you have org-trim, s-trim, ... > > OTOH, I think the question is not only about leading space, but also > about space after newline chars. Does your function handle them ? > > FWIW, if I had to write such a function, I would do as follows : if the > first line is indented, remove that amount of space on every line. If > the second line is indented, remove that amount of space on every line > (except the first). (And eventually yank.) > > The reason for checking the 2nd line is that I often have text like: >> bla bla bla >> bla bla bla >> bla bla bla > and I kill the text from the end of the prompt to the end of the "bla > bla". Yanking it then gives: >> bla bla bla >> bla bla bla >> bla bla bla > which is ugly. > > Not sure if that's what Eric had in mind though. That's actually exactly the situation that prompted my question, but I seem to run into similar situations all the time: yanking a multi-line address from a BBDB record, copying a few sexps out of the middle of a deeply-indented function and yanking them into an email, etc. I'm going to give Drew's solution test-drive, but I also like your idea of "cascading" indentation deletion. Thanks, Eric