From: Jose Cuthberto
Subject: Re: How to  PICK  the CTRL-u argument from the file or some other method, with EXAMPLE
Date: 
Message-ID: <cf2523f3.0409231402.44ab9a0f@posting.google.com>
····@Aumara.zzn.com (Jose Cuthberto) wrote in message news:<····························@posting.google.com>...
> An example would clarify the problem:
> 
> Suppose you want to paste a single killed line (in kill buffer using two C-k's)
> you can trivially do it like this:
> 
> C-u 2 C-y
> 
> In this case you had to enter the numbers.
> 
> I have a file like this:
> 
> 5
> line1
> 6
> line2
> 
> Now I must convert it to a file with 5 line1's and 6 line2's and so on.
> It is a long file.
> 
> How do I pick 5 and put it into C-u so that it is done 5 times.
> 
> I can write macros. and I can also write single line lisp functions.
> Unfortunately there is no yank cammand that can take the argument 5.
> nor do i know the lisp function that can take the count and pass it to 
> lisp function yank. I would want to avoid writing a loops, and vars etc.
> 
> Thanks to the star who can help!!!
> 
> jose


still waiting for a solution

From: Chris F.A. Johnson
Subject: Re: How to  PICK  the CTRL-u argument from the file or some other method, with EXAMPLE
Date: 
Message-ID: <2rgvr7F1aej4cU1@uni-berlin.de>
On 2004-09-23, Jose Cuthberto wrote:
> ····@Aumara.zzn.com (Jose Cuthberto) wrote in message news:<····························@posting.google.com>...
>> An example would clarify the problem:
>> 
>> Suppose you want to paste a single killed line (in kill buffer using two C-k's)
>> you can trivially do it like this:
>> 
>> C-u 2 C-y
>> 
>> In this case you had to enter the numbers.
>> 
>> I have a file like this:
>> 
>> 5
>> line1
>> 6
>> line2
>> 
>> Now I must convert it to a file with 5 line1's and 6 line2's and so on.
>> It is a long file.
>> 
>> How do I pick 5 and put it into C-u so that it is done 5 times.
>> 
>> I can write macros. and I can also write single line lisp functions.
>> Unfortunately there is no yank cammand that can take the argument 5.
>> nor do i know the lisp function that can take the count and pass it to 
>> lisp function yank. I would want to avoid writing a loops, and vars etc.
>> 
>> Thanks to the star who can help!!!
>
> still waiting for a solution

    Still wondering why it was posted to comp.unix.shell.

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
From: David Golden
Subject: Re: How to  PICK  the CTRL-u argument from the file or some other method, with EXAMPLE
Date: 
Message-ID: <PqI4d.31892$Z14.10693@news.indigo.ie>
Chris F.A. Johnson wrote:

>> still waiting for a solution
> 
>     Still wondering why it was posted to comp.unix.shell.
> 

Heh. Remember it IS emacs, after all. It IS (or typically includes "out-of-box"
an implementation of) an sh-family shell called eshell. 

http://www.newartisans.com/johnw/eshell.html
"""
Eshell is a command shell implemented entirely in Emacs Lisp. It invokes no external 
processes beyond those requested by the user. It is intended to be a functional 
replacement for command shells such as bash, zsh, rc, 4dos; since Emacs itself is
capable of handling most of the tasks accomplished by such tools. 
"""


So, on your average linux install (okay for the pedants, linux is not unix exactly,
but emacs works on real unix too) one can do the following (tested, actual
copy+pastes from my system):

# adduser tryme
# chsh -s /usr/bin/emacs tryme
# su - tryme

File Edit Options Buffers Tools Help                                        
Welcome to GNU Emacs, one component of a Linux-based GNU system.
[*** snipped blurb]
----:---F1  *scratch*         (Lisp Interaction)--L1--All----------------------
For information about the GNU Project and its goals, type C-h C-p.

[*** Now type M-x eshell]

File Edit Options Buffers Tools Help
Welcome to the Emacs shell

~ $ cd /usr
/usr $ ls
X11R6  bin  doc  games  include  info  lib  local  sbin  share  src
/usr $ echo $SHELL
/usr/bin/emacs
/usr $ echo $TERM
xterm
/usr $ 

----:---F1  *eshell*          (EShell)--L11--All-------------------------------
From: Johan Ur Riise
Subject: Re: How to  PICK  the CTRL-u argument from the file or some other method, with EXAMPLE
Date: 
Message-ID: <87oejwo8mt.fsf@riise-data.no>
····@Aumara.zzn.com (Jose Cuthberto) writes:

> 
> 
> still waiting for a solution

Oh lord - won't you buy me - a mercedes benz..
From: Alan Crowe
Subject: Re: How to  PICK  the CTRL-u argument from the file or some other method, with EXAMPLE
Date: 
Message-ID: <86pt4b27o3.fsf@cawtech.freeserve.co.uk>
Jose Cuthberto risks repetitive strain injury:
> Now I must convert it to a file with 5 line1's and 6 line2's and so on.
> It is a long file.

M-x run-lisp

to fire up your Common Lisp.
Then

(defun multiply-lines (in-file out-file)
    (with-open-file (in in-file :direction :input)
      (with-open-file (out out-file
			   :direction :output
			   :if-exists :supersede)
	(loop for count = (read in nil nil)
	      while (integerp count)
	      do (let ((buffer (read-line in)))
		   (loop repeat count
                         do (princ buffer out)
                            (terpri out)))))))

(multiply-lines "temp-count-lines" "temp-dup-lines-1")