help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yank without indentation?


From: Eric Abrahamsen
Subject: Re: yank without indentation?
Date: Fri, 06 Jun 2014 08:36:34 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

Nicolas Richard <address@hidden> writes:

> Thorsten Jolitz <address@hidden> writes:
>
>> Eric Abrahamsen <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]