Subject: Vim xmms front-end Rev. 2

From: Shlomi Fish <[email-masked]>
Date: Tue, 12 Feb 2002 14:58:47 +0200 (IST)

The Vim macros are:

map <F3> 0"5y$:!xmms -e '<C-R>5'<CR><CR>
map <S-F3> 0"5y$:!xmms '<C-R>5'<CR><CR>

while the command used to invoke gvim is:

ls | sed s/\'/\'\\\\\'\'/g | gvim -

(which I turned into a script name mpls).

Now, the sed stuff is a kludge and it may execute an arbitrary command if
the line contains say:

'`rm -fr $HOME`'

(!)

Does anybody know of a way for vim to:

1. Input a line into a register.
2. Turn any ' in the register to '\'' .
3. Put the result in another register  or in a separate register.

It's just that my vi programming knowledge is a bit rusty.

Regards,

	Shlomi Fish

----------------------------------------------------------------------
Shlomi Fish        [email-masked]
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"

---

From: Shlomi Fish <[email-masked]>
Date: Tue, 12 Feb 2002 15:32:28 +0200 (IST)

The macros are now:

map <F3> 0"5y$ji<CR><ESC>ki<C-R>5<ESC>:s/'/'\\''/ge<CR>0"5y$:!xmms -e '<C-R>5'<CR><CR>ddk

map <S-F3> 0"5y$ji<CR><ESC>ki<C-R>5<ESC>:s/'/'\\''/ge<CR>0"5y$:!xmms '<C-R>5'<CR><CR>ddk

And the command to execute is again "ls | gvim -". Now single-quotes (and
all other charactersare) are handled correctly and the code is fool-proof,
and cannot execute arbitrary commands.

What I did was copy the register to a new line. Exec a regex substitute on
it to handle the single quotes. Then, yank it again and use it, and when
everything is finished delete the line and position myself on the original
line.

I dare say these vi macros look like line noise, but the funny thing is I
could spot some patterns there and understand it. I don't know how capable
I am of reading other people's vi macros, but it's a start.

Kudos,

	Shlomi Fish