all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: yank without indentation?
Date: Fri, 06 Jun 2014 08:36:34 +0800	[thread overview]
Message-ID: <877g4uvppp.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 87ppine5kn.fsf@geodiff-mac3.ulb.ac.be

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
>
>> Eric Abrahamsen <eric@ericabrahamsen.net> 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:
>> <prompt> 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




  reply	other threads:[~2014-06-06  0:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 15:13 yank without indentation? Eric Abrahamsen
2014-06-05 15:18 ` Thorsten Jolitz
2014-06-05 15:31   ` Nicolas Richard
2014-06-06  0:36     ` Eric Abrahamsen [this message]
2014-06-05 19:19 ` Grant Rettke
2014-06-05 19:25 ` Jacob Gerlach
2014-06-05 22:26   ` Robert Thorpe
2014-06-06  6:27     ` Eli Zaretskii
2014-06-05 23:29   ` Drew Adams
2014-06-06  0:40     ` Eric Abrahamsen
2014-06-10  0:00   ` Ken Goldman

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=877g4uvppp.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /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.