jed-users mailing list

[2006 Date Index] [2006 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: pasting text using the X clipboard


On Tue, Sep 12, 2006 at 12:12:22AM +0200, Juergen Lemke wrote:
> Hello everyone,
> 
> I have noticed that whenever I paste a multi-line
> selection of text into an xterm running jed (in Text
> mode) I need to manually remove all the white space at
> the beginning of each line. One work-around I have
> found is to first run the no_mode function, press the
> middle mouse button to paste the text and then revert
> to the previous mode.
> 
> Is there a way to automate this process? Is it
> possible for jed to figure out that text is being
> pasted from the X clipboard and temporarily revert to
> "no mode" before the text is inserted?
> 

To remove whitespace at the beginning of each line, you are likely
to want to write an slang function and bind it to a key.

Another approach is to highlight a set of lines and filter them
through a script.  If you have Python installed on your machine and
the filter module for jed, you can paste your lines, then filter
them through the following Python script:

    #!/usr/bin/env python
    import sys
    def remove_ws():
        lines = sys.stdin.readlines()
        for line in lines:
            line = line.lstrip()
            sys.stdout.write(line)
    remove_ws()

Note that (if you are not a Python person) the leading whitespace
in the above code *does* matter.

Yes, yes, I know.  That could be re-written in Perl in 3 lines or
less.  Here is a perl command that you could filter a set of lines through
to remove whitespace at the beginning of each line:

    perl -p -e "s/^\ \t*//"

Dave

-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2006 date index] [2006 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]