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

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

Re: yank without indentation?


From: Nicolas Richard
Subject: Re: yank without indentation?
Date: Thu, 05 Jun 2014 17:31:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.91 (gnu/linux)

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.

-- 
Nico.



reply via email to

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