script to download scripts from vim.org

6 views
Skip to first unread message

Amit Agarwal

unread,
Mar 16, 2011, 12:17:06 PM3/16/11
to vim...@googlegroups.com
Hi All,

I have written a script to download scripts for vim directly from the
www.vim.org site.
Please find a link to the same :
http://blog.amit-agarwal.co.in/2011/03/09/all-in-one-solution-for-all-the-scripts-of-vim-from-vim-org/

I would like to put that on www.vim.org site, if that is possible.
Please help me with your comments and reviews and if you think this will
be helpful for the vim users.

--
Thanks,
-aka
http://blog.amit-agarwal.co.in
http://shop.amit-agarwal.co.in
http://amit-agarwal.com

Tom Link

unread,
Mar 17, 2011, 2:25:13 AM3/17/11
to vim_use
> I have written a script to download scripts for vim directly from thewww.vim.orgsite.
> Please find a link to the same :http://blog.amit-agarwal.co.in/2011/03/09/all-in-one-solution-for-all...

Would it be fit to be added to http://vim-scripts.org/vim/tools.html
which seems to be the most complete list of similar tools up to date?

Regards,
Tom

Marc Weber

unread,
Mar 17, 2011, 3:01:17 AM3/17/11
to vim_use
Hi Amit Agarwal's,

I did a small review.

Summary:
- do research before starting work
- Learn how to code. This means avoiding duplication.
Nice comments are fine. Working code is always better.
- You can publish it nicer. Its hard to read within the small text box..
(eg paste sites such as dpaste.com are nice for short time hosting)

Nobody should spend another minute on this script cause it contains obvious
bugs.

So if you'd upload it to Vim I'd ignore or down vote it because I don't like
the style (long lines) and because of the flaws I've written down below.
(You keep trying and ask for feedback. You'll learn fast)

> I would like to put that on www.vim.org site, if that is possible.

You have to register. Then you can upload it..

> Please help me with your comments and reviews and if you think this will
> be helpful for the vim users.

You're too late - you should do better research.
https://github.com/MarcWeber/vim-addon-manager/blob/master/doc/vim-addon-manager.txt
Scroll down to "related work".

Vim users do no longer need yet another solution. I encourage you to
join this (or one of the other) efforts.

If you want others to review your code upload it somewhere else in an
indentation preserving way (oh there is a link .. found it)

Moreover your script does not handle:
- tar
- zip
- (.vba) (vimball)
archives.

Learn to do research - and join consider asking on irc or the
mailinglist unless its fun for you to spend your time on reinventing the
wheel :)

issues:
- your text version http://blog.amit-agarwal.co.in/wp-content/uploads/2011/03/get_vim_scripts.txt
is lacking the shebang #!/bin/sh line so won't run at all?
You should be using set -e always (if something fails the script should
fail)

The "revision" is the same, but the text contents are not. So your revision
system does not work.
(I was comparing the text box with the .txt file)

- some comments don't match. NAME: get_list should be search_list ..
(This happens to me as well. That's why I only use comments without
names - and only comments if necessary ..)

- Have you ever run this code !?
[#!/bin/bash]:

while true
do

A ; is missing.

- The link above contains:

if [ "x$1" = "x" ]
then
cat $tmp_file | grep width| grep script_id= |sed 's/.*script_id=//'|tr -d "\""|tr ">" " "|sed 's/<.*//' | tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' |grep -i "$text"|$PAGER
else
cat $tmp_file | grep width| grep script_id= |sed 's/.*script_id=//'|tr -d "\""|tr ">" " "|sed 's/<.*//' | tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' |grep -i "$text"|$PAGER
fi

Do you want to know how much time I've spend on comparing char by char to
find out that both are the same lines?

Do something like this instead:

my_filter(){
cat \
| sed .. \
| grep .. \
}

if ..
then
input | filter | output
else
input | filter | output
fi

Its much more readable!

That's enough to make me move your script to /dev/null.

Marc Weber

Christian Brabandt

unread,
Mar 17, 2011, 3:42:08 AM3/17/11
to vim...@googlegroups.com
On Thu, March 17, 2011 8:01 am, Marc Weber wrote:
> - Have you ever run this code !?
> [#!/bin/bash]:
>
> while true
> do
>
> A ; is missing.

No, that is perfectly valid.

regards,
Christian

Marc Weber

unread,
Mar 17, 2011, 3:59:47 AM3/17/11
to vim_use
Excerpts from Christian Brabandt's message of Thu Mar 17 07:42:08 +0000 2011:

> No, that is perfectly valid.
You're correct. I apologize for it. Sorry.

Marc Weber

Amit Agarwal

unread,
Mar 17, 2011, 12:42:24 PM3/17/11
to vim...@googlegroups.com
I guess yes, I have sent a email to the address mentioned on the page.
Thanks for the suggestion.
>
> Regards,
> Tom

Amit Agarwal

unread,
Mar 17, 2011, 1:15:35 PM3/17/11
to vim...@googlegroups.com
On Thu, 2011-03-17 at 07:01 +0000, Marc Weber wrote:
> Hi Amit Agarwal's,
>
> I did a small review.
>
> Summary:
> - do research before starting work
I did. If you feel I missed something in my research, point me to it.

> - Learn how to code. This means avoiding duplication.
> Nice comments are fine. Working code is always better.
I really did not see any code in the script that does not work. Can you
be more precise.

> - You can publish it nicer. Its hard to read within the small text box..
> (eg paste sites such as dpaste.com are nice for short time hosting)
Thanks for the feedback. I have corrected the issue and now the site
should look much better.

>
> Nobody should spend another minute on this script cause it contains obvious
> bugs.
Kindly point them. I have no issue no one spending a minute on it but
would really appreciate if you could tell me the reasons. I hope you
have tried to use the script before saying this and understood what the
script does.

>
> So if you'd upload it to Vim I'd ignore or down vote it because I don't like
> the style (long lines) and because of the flaws I've written down below.
> (You keep trying and ask for feedback. You'll learn fast)
This I completely agree.

>
> > I would like to put that on www.vim.org site, if that is possible.
> You have to register. Then you can upload it..
>
> > Please help me with your comments and reviews and if you think this will
> > be helpful for the vim users.
> You're too late - you should do better research.
> https://github.com/MarcWeber/vim-addon-manager/blob/master/doc/vim-addon-manager.txt
> Scroll down to "related work".
I did not find anything similar in this link. My script can be used to
list the recent additions, list the scripts with their ID number, add to
GLVS (GetLatestVimScripts), show you the description given the script
ID, search for text in description of plugin and so on. Can you point me
to some script, which does all this. I might have missed finding the
right tool and ended up re-inventing the wheel.

>
> Vim users do no longer need yet another solution. I encourage you to
> join this (or one of the other) efforts.
>
> If you want others to review your code upload it somewhere else in an
> indentation preserving way (oh there is a link .. found it)
>
> Moreover your script does not handle:
> - tar
> - zip
> - (.vba) (vimball)
> archives.
Yes. That is clearly mentioned in the first line of my original post
itself.

>
> Learn to do research - and join consider asking on irc or the
> mailinglist unless its fun for you to spend your time on reinventing the
> wheel :)
Not all wheels are same. I don't want to put a Car wheel in Truck. If
you like the wheel, its completely your choice.

>
> issues:
> - your text version http://blog.amit-agarwal.co.in/wp-content/uploads/2011/03/get_vim_scripts.txt
> is lacking the shebang #!/bin/sh line so won't run at all?
That because my server will not allow shebang. So, you can run with ".
name" or "bash name".

> You should be using set -e always (if something fails the script should
> fail)
I agree. In case of this script mostly the failures should not result in
the script to terminate as the error could possibly not affect anything
else.

>
> The "revision" is the same, but the text contents are not. So your revision
> system does not work.
> (I was comparing the text box with the .txt file)
Did you do a diff?

>
> - some comments don't match. NAME: get_list should be search_list ..
> (This happens to me as well. That's why I only use comments without
> names - and only comments if necessary ..)
Something that can be corrected is better than something that has to be
created, I believe. I might be wrong but like it so follow it.

>
> - Have you ever run this code !?
> [#!/bin/bash]:
>
> while true
> do
>
> A ; is missing.
>
> - The link above contains:
>
> if [ "x$1" = "x" ]
> then
> cat $tmp_file | grep width| grep script_id= |sed 's/.*script_id=//'|tr -d "\""|tr ">" " "|sed 's/<.*//' | tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' |grep -i "$text"|$PAGER
> else
> cat $tmp_file | grep width| grep script_id= |sed 's/.*script_id=//'|tr -d "\""|tr ">" " "|sed 's/<.*//' | tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377' |grep -i "$text"|$PAGER
> fi
>
> Do you want to know how much time I've spend on comparing char by char to
> find out that both are the same lines?
I think it should not take more than couple of seconds to figure that
out. That was a redundant code and had left it by mistake. Appreciate
the feedback on this.

>
> Do something like this instead:
>
> my_filter(){
> cat \
> | sed .. \
> | grep .. \
> }
>
> if ..
> then
> input | filter | output
> else
> input | filter | output
> fi
Yes, this would definately be better.

>
> Its much more readable!
>
> That's enough to make me move your script to /dev/null.
>
> Marc Weber
>

--

ZyX

unread,
Mar 17, 2011, 1:50:10 PM3/17/11
to vim...@googlegroups.com
Reply to message «script to download scripts from vim.org»,
sent 19:17:06 17 March 2011, Thursday
by Amit Agarwal:

Some notes:
1. «grep pat1 | grep pat2 | sed 's/pat3/repl/g'» can be replaced with a single
«sed '/pat1/! d; /pat2/! d; s/pat3/repl/g'».
2. Most tr calls can also be merged into sed command.
3. The whole


tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377'

can be replaced with
trd="tr -d '\\001-\\011\\013\\014\\016-\\037\\200-\\377'"
$trd
You don't need so many quotes and as it is widely used the you should either put
it into function or use a variable.
4. Why are you using menu with `read read_choice' (and other reads) and not
command-line options? It reminds me of the time when I learned programming at
school and wrote programs with scanf() where now I use getopt.
5. I would have used perl for it. And no HTML regex parsing!!!
6. Code should be put under VCS if you want someone to help you. For simple code
snippets there are gists on github, but I'd used fully-featured repositories on
bitbucket (not because github does not have ones alongside with gists, but
because I don't like git. On bitbucket gist request has status open and is two
years old).

Original message:

signature.asc

Marc Weber

unread,
Mar 17, 2011, 7:22:39 PM3/17/11
to vim_use
Hi Amit Agarwal,

I've already admitted that I was badly mistaken about the "do while ..".

1) your presentation: still indentation is missing

2) What is the real goal? What do we want?


1) Your presentation:

That you present a big "box" showing the (no longer formatted code)
will cause trouble. Even though the box is "huge" now formatting is
still gone. There is no way sending patches this way.
If I see code which is not indented I instantly think that you don't
care about your code (so I start looking for more issues).
So rather then doing your own thing use a service such as github which
will allow users to comment your code, fork and send patches or use an issue
tracker.

Reading like this turns me off because missing indentation is always causing
much more work to understand it.

download_list()
{
downloaded=1
if [ ! -f $tmp_file ]
then
wget -O $tmp_file 'http://www.vim.org/scripts/script_search_results.php?&amp;show_me=4000&amp;result_ptr=0' -o /dev/null
else
echo "using the existing $tmp_file"
fi
}

And thats the first impression a visitor gets. So use <pre> </pre> or such
rather than whatever you did or use github, gitorious, or any of the other
public code hosting services.

2) What is the real goal? What do we want?

What's most important to know?

Can you describe briefly what your script does what you didn't find on
vim.sf.net?

Eg why do you prefer your script over using the home page (vim.sf.net)?

I'm asking because your script identifies flaws of the homepage we should fix.

You should not have to parse HTML in order to get the info. We should create an
API. (PyPi, RubyGems, .. they all have it. Only Vim is still xx years old in
this regard). We should move forward or people will choose other tools.

Also I'd like to work towards having one Vim plugin handling all the
needs of todays users about script querying and installation.

vim-addon-manager is the result of my last attempt and I think it gets
the job done much better than anything which was available before ti.
It still is very weak: You have to browse vim.sf.net to find out which plugins
to install and I'm pretty sure there are more issues.

Would you be interested integrating your ideas into VAM
(or a similar plugin) so that it also runs on Windows and that more
users will have access to it naturally?

Instead of parsing HTML it should be based on a specific API call such as

vim.sf.net/api.php?query-all-scripts-matching-word=XY

or the like. The result could be json which can be prased by Vim:
https://github.com/MarcWeber/vim-addon-json-encoding
Then Vim buffers and highlighting could be used to present the query result to
users?

Please talk about what made you write your script - so thaw can slowly
improve the overall situation for all users.

I mean vim.sf.net having pages talking about Vim 5 (About Vim -> "for
vim 5 users"). This shows that its partially updated maybe no longer fitting
the needs of todays users. If that's the case we should collect thoughts and
improve the situation.

If you need help with github or the like you can contact me anytime (I'm also
on irc very often).

Blogs are nice - but they are bad at hosting code. They should be used to talk
about code referring to code hosted somewhere else.

Marc Weber

Amit Agarwal

unread,
Mar 18, 2011, 12:06:58 AM3/18/11
to vim...@googlegroups.com
Hi Marc Weber,

On Thu, 2011-03-17 at 23:22 +0000, Marc Weber wrote:
> Hi Amit Agarwal,
>
> I've already admitted that I was badly mistaken about the "do while ..".
>
> 1) your presentation: still indentation is missing
>
> 2) What is the real goal? What do we want?
>
>
> 1) Your presentation:
>
> That you present a big "box" showing the (no longer formatted code)
> will cause trouble. Even though the box is "huge" now formatting is
> still gone. There is no way sending patches this way.
> If I see code which is not indented I instantly think that you don't
> care about your code (so I start looking for more issues).

I will host the code on github or sf.net. Also will correct the
indentation issue.

> So rather then doing your own thing use a service such as github which
> will allow users to comment your code, fork and send patches or use an issue
> tracker.
>
> Reading like this turns me off because missing indentation is always causing
> much more work to understand it.
>
> download_list()
> {
> downloaded=1
> if [ ! -f $tmp_file ]
> then
> wget -O $tmp_file 'http://www.vim.org/scripts/script_search_results.php?&amp;show_me=4000&amp;result_ptr=0' -o /dev/null
> else
> echo "using the existing $tmp_file"
> fi
> }
>
> And thats the first impression a visitor gets. So use <pre> </pre> or such
> rather than whatever you did or use github, gitorious, or any of the other
> public code hosting services.
>
> 2) What is the real goal? What do we want?
>
> What's most important to know?
>
> Can you describe briefly what your script does what you didn't find on
> vim.sf.net?

Currently I am using GLVS for managing my scripts. The reason for using
GLVS is that it does not change anything that I am used to. It keeps the
scripts in the plugin directories, so if I need to copy or back the
directory, I need not worry. When I need a new script, I search for it.
Download it. Move it to plugins directory. Add it to GLVS. Thats a lot
of work and that is what precisely my script will do.

>
> Eg why do you prefer your script over using the home page (vim.sf.net)?

It does not give me the flexibility a script would give.


>
> I'm asking because your script identifies flaws of the homepage we should fix.
>
> You should not have to parse HTML in order to get the info. We should create an
> API. (PyPi, RubyGems, .. they all have it. Only Vim is still xx years old in
> this regard). We should move forward or people will choose other tools.
>
> Also I'd like to work towards having one Vim plugin handling all the
> needs of todays users about script querying and installation.

Nothing like it.


>
> vim-addon-manager is the result of my last attempt and I think it gets
> the job done much better than anything which was available before ti.
> It still is very weak: You have to browse vim.sf.net to find out which plugins
> to install and I'm pretty sure there are more issues.

Also the database for the scripts is in another script, which I did not
like. Any addition in vim site would require addition of the same in
this script.


>
> Would you be interested integrating your ideas into VAM
> (or a similar plugin) so that it also runs on Windows and that more
> users will have access to it naturally?

I would not say no. But I would be interested only in plugins that do
not change the way the directory is structured. I also would be very
much interested in one single solution.

>
> Instead of parsing HTML it should be based on a specific API call such as
>
> vim.sf.net/api.php?query-all-scripts-matching-word=XY
>
> or the like. The result could be json which can be prased by Vim:
> https://github.com/MarcWeber/vim-addon-json-encoding
> Then Vim buffers and highlighting could be used to present the query result to
> users?
>
> Please talk about what made you write your script - so thaw can slowly
> improve the overall situation for all users.
>
> I mean vim.sf.net having pages talking about Vim 5 (About Vim -> "for
> vim 5 users"). This shows that its partially updated maybe no longer fitting
> the needs of todays users. If that's the case we should collect thoughts and
> improve the situation.
>
> If you need help with github or the like you can contact me anytime (I'm also
> on irc very often).
>
> Blogs are nice - but they are bad at hosting code. They should be used to talk
> about code referring to code hosted somewhere else.

They are not bad if used properly. I made a mistake of not posting the
code correctly. Will be correcting it over the weekend.

Amit Agarwal

unread,
Mar 18, 2011, 12:10:50 AM3/18/11
to vim...@googlegroups.com
On Thu, 2011-03-17 at 20:50 +0300, ZyX wrote:
> Reply to message «script to download scripts from vim.org»,
> sent 19:17:06 17 March 2011, Thursday
> by Amit Agarwal:
>
> Some notes:
> 1. «grep pat1 | grep pat2 | sed 's/pat3/repl/g'» can be replaced with a single
> «sed '/pat1/! d; /pat2/! d; s/pat3/repl/g'».
> 2. Most tr calls can also be merged into sed command.
> 3. The whole
> tr -d '\001'-'\011''\013''\014''\016'-'\037''\200'-'\377'
> can be replaced with
> trd="tr -d '\\001-\\011\\013\\014\\016-\\037\\200-\\377'"
> $trd
> You don't need so many quotes and as it is widely used the you should either put
> it into function or use a variable.

Yes, agree with this. This started with a one liner and became a
complete script so forgot to do all this. Will make these changes.


> 4. Why are you using menu with `read read_choice' (and other reads) and not
> command-line options? It reminds me of the time when I learned programming at
> school and wrote programs with scanf() where now I use getopt.

I wanted a while loop so that user can stay in the script and do
multiple things in one go. Can getopts be used in that situation. Please
help me on how to do it.

> 5. I would have used perl for it. And no HTML regex parsing!!!

Personal preference, I would say.

> 6. Code should be put under VCS if you want someone to help you. For simple code
> snippets there are gists on github, but I'd used fully-featured repositories on
> bitbucket (not because github does not have ones alongside with gists, but
> because I don't like git. On bitbucket gist request has status open and is two
> years old).

I am thinking of putting it into sf.net now. I just wanted to get a
opinion first as to wheather it is useful or not.


>
> Original message:
> > Hi All,
> >
> > I have written a script to download scripts for vim directly from the
> > www.vim.org site.
> > Please find a link to the same :
> > http://blog.amit-agarwal.co.in/2011/03/09/all-in-one-solution-for-all-the-s
> > cripts-of-vim-from-vim-org/
> >
> > I would like to put that on www.vim.org site, if that is possible.
> > Please help me with your comments and reviews and if you think this will
> > be helpful for the vim users.

--

Amit Agarwal

unread,
Mar 18, 2011, 12:14:33 AM3/18/11
to vim...@googlegroups.com
On Wed, 2011-03-16 at 23:25 -0700, Tom Link wrote:

The script is added in the tools page.

>
> Regards,
> Tom

Marc Weber

unread,
Mar 17, 2011, 11:37:22 PM3/17/11
to vim_use
Excerpts from Amit Agarwal's message of Fri Mar 18 04:06:58 +0000 2011:
> +AD4 Can you describe briefly what your script does what you didn't find on
> +AD4 vim.sf.net?

> Currently I am using GLVS for managing my scripts.
GLVS was written when git, mercurial etc were less popular.
Also one of the goals of VAM is improve code sharing.
So a plugin can say it depends on another library / plugin.
Eg most of my plugins depend on tlib.

GLVS does not do it (yet). We can discuss again whether my choice was
good to use an additional external -addon-info.txt file keeping this
info.

Example:
https://github.com/MarcWeber/vim-addon-async/blob/master/vim-addon-async-addon-info.txt

> GLVS is that it does not change anything that I am used to. It keeps the
> scripts in the plugin directories, so if I need to copy or back the
> directory, I need not worry.

You're right. This works well unless a "plugin" distribution starts
being a vimball or a zip which means its made up of many files.

Example:

plugin/A.vim
plugin/B.vim
doc/A.txt
doc/B.txt

Now you decide that you want to update B. deleting 2 files is doable.
But many plugins have even more files.
What about tar xfz into ~/.vim ? Bad idea: The new version of a plugin
could have rename A.vim to A-foo.vim. Then you have both: old and new
version.

So you would have to keep track of files:

= plugin A contents.txt:
plugin/A.vim
doc/A.vim
=

Then you know what to remove.. (Of course you can write scripts for this
..)

So what does VAM do different?
The file layout looks like this:

vam/
A/
plugin/A.vim
doc/A.vim
B/
plugin/B.vim
doc/B.vim

so getting rid of a plugin is as easy as deleting a directory.
Because vam (in docs referred to as ~/vim-addons) can be put into
~/.vim/somewhere you can still backup ~/.vim, copy it around and be
done.

Why not manipulate runtimepath yourself? Because rtp handing of Vim is
not perfect. eg after/*/*.vim files are not sourced at all.

> Also the database for the scripts is in another script, which I did not
> like. Any addition in vim site would require addition of the same in
> this script.

You don't have to use it. You can copy paste the sources you care about
into your ~/.vimrc then its more like PATHOGEN.

However there are reasons for this external additional "script":
1) a way to point users to enhanced versions. The option to "deprecate" scripts
2) add git/mercurial/.. sources of plugins (which may not even be on
vim.sf.net)
3) some plugins have bad plugin type. So the extra script fixes them.
(Its only about 8-10 plugins. Still VAM tries to get it right for the user
the first time. So some minimal patch patching has to be done ..)

Again - these feature could be put on vim.sf.net. However when I wrote
VAM i wasn't in touch with Bram - so changing the homepage was no option.
Adding an upstream url to the scripts is on my TODO. Then you can associate git
or mercurial sources with your script.

Currently the section of deprecated plugins is small. But we can improve it over time:

" deprecations {{{1
let s:plugin_sources['scala']['deprecated'] = "The syntax doesn't highlight \"\"\" strings correctly. I don't know how to contact the maintainer. So I moved the file and a fix into vim-addon-scala"
let s:plugin_sources['rubycomplete']['deprecated'] = "you should consider using ruby-vim instead"
let s:plugin_sources['idutils']['deprecated'] = "greputils supersedes this plugin"
let s:scm_plugin_sources['snipmate']['deprecated'] = "Consider using my fork snipMate because it autoreloads your snippet files and automatically fixes indentation (visually select snippet then <cr>)"
"}}}

The other reason is that I didn't think of getting a list of plugins the way you did.
I iterate over all script?nr=.. urls using VimL regex to extract the info out
of the HTML. (which was quite a lot of work to get right) and which takes time.
So I want to fix this in the future by introducing an API.

I thought it would be benefical to get as much info as possible so that browsing the list
could be implemented later (which never happened ..)

If a maintained set of plugin is not what users want we can easily ask all
users to fetch the info about available plugins from vim.sf.net's API instead.
However 1) and 2) mentioned above will not be available.

If 1) and 2) was implemented on vim.sf.net using a shell script can turn into a
night mare more easily. Shell scripts don't scale very well. I tried getting a
patch into top-git once. And I'm sure it took more than twice the time it
should have take only because it was written in bash only.

Your script is still simple so its ok to use bash. But if you tried adding
features such as untarring, ...

> +AD4 (or a similar plugin) so that it also runs on Windows and that more
> +AD4 users will have access to it naturally?


> I would not say no. But I would be interested only in plugins that do
> not change the way the directory is structured. I also would be very
> much interested in one single solution.

I hope you understood that the way is not really changed. Each plugin is put
into its own directory instead. Also some additional files are kept:
- the original archive (so that diffing can be done when a plugin can be updated)
- the plugin versions (so that VAM knows which plugin to update)

I agree that the effort VAM does doesn't make sense if you use only 3-4 plugins
containing a single .vim file only.

Today I'd like to propagate this plugin layout:

plugin/A.vim (the user interfac: mappings, commands and autocommands)
autoload/A.vim (the implementation: loaded only "as needed")
and of course a doc or a README file

So all plugins I will write will always have about 3 files at least.

> They are not bad if used properly. I made a mistake of not posting the
> code correctly. Will be correcting it over the weekend.

Having some indentation improves the credibility a lot.

Anyway: I'll take a note and I'll add your script to the related work section
of VAM in some days because it is somewhat related.

Marc Weber

ZyX

unread,
Mar 18, 2011, 12:49:18 AM3/18/11
to vim...@googlegroups.com
Reply to message «Re: script to download scripts from vim.org»,
sent 07:10:50 18 March 2011, Friday
by Amit Agarwal:

> I wanted a while loop so that user can stay in the script and do
> multiple things in one go. Can getopts be used in that situation. Please
> help me on how to do it.

The getopt is to be used for user not to stay in the script but launch it each
time he needs to do something; it is more useful then menu because 0) if one
runs your script with a typo (in plugin name, for example), it is more easily
corrected in shell command-line then; 1) I prefer Z line editor to any input
editing read provides; 2) it makes your script able to be used in users'
scripts. If you make scripts list stay in /tmp after script exits and make a
code that will ignore it if it is 1 hour old, then this will be possible.

> +AD4 5. I would have used perl for it. And no HTML regex parsing+ACEAIQAh


> Personal preference, I would say.

Perl - yes. «No HTML regex parsing» - no: HTML should not be parsed with regex
because it is not a regular language and thus every regex parser is very prone
to errors, especially when something changes even slightly.

By the way, why you message contains lots of {plus}AD4, {plus}ALs and other
{plus}A{something}? It is not very easy to find you reply with these.

Original message:
> On Thu, 2011-03-17 at 20:50 +-0300, ZyX wrote:
> +AD4 Reply to message +AKs-script to download scripts from vim.org+ALs,
> +AD4 sent 19:17:06 17 March 2011, Thursday
> +AD4 by Amit Agarwal:
> +AD4
> +AD4 Some notes:
> +AD4 1. +AKs-grep pat1 +AHw grep pat2 +AHw sed 's/pat3/repl/g'+ALs can be
> replaced with a single +AD4 +AKs-sed '/pat1/+ACE d+ADs /pat2/+ACE d+ADs
> s/pat3/repl/g'+ALs. +AD4 2. Most tr calls can also be merged into sed
> command.
> +AD4 3. The whole
> +AD4 tr -d
> '+AFw-001'-'+AFw-011''+AFw-013''+AFw-014''+AFw-016'-'+AFw-037''+AFw-200'-'
> +AFw-377' +AD4 can be replaced with
> +AD4 trd+AD0AIg-tr -d
> '+AFwAXA-001-+AFwAXA-011+AFwAXA-013+AFwAXA-014+AFwAXA-016-+AFwAXA-037+AFwA
> XA-200-+AFwAXA-377'+ACI +AD4 +ACQ-trd
> +AD4 You don't need so many quotes and as it is widely used the you should
> either put +AD4 it into function or use a variable.


>
> Yes, agree with this. This started with a one liner and became a
> complete script so forgot to do all this. Will make these changes.

> +AD4 4. Why are you using menu with +AGA-read read+AF8-choice' (and other
> reads) and not +AD4 command-line options? It reminds me of the time when I
> learned programming at +AD4 school and wrote programs with scanf() where


> now I use getopt.
>
> I wanted a while loop so that user can stay in the script and do
> multiple things in one go. Can getopts be used in that situation. Please
> help me on how to do it.
>

> +AD4 5. I would have used perl for it. And no HTML regex parsing+ACEAIQAh


>
> Personal preference, I would say.
>

> +AD4 6. Code should be put under VCS if you want someone to help you. For
> simple code +AD4 snippets there are gists on github, but I'd used
> fully-featured repositories on +AD4 bitbucket (not because github does not
> have ones alongside with gists, but +AD4 because I don't like git. On
> bitbucket gist request has status open and is two +AD4 years old).


>
> I am thinking of putting it into sf.net now. I just wanted to get a
> opinion first as to wheather it is useful or not.

> +AD4
> +AD4 Original message:
> +AD4 +AD4 Hi All,
> +AD4 +AD4
> +AD4 +AD4 I have written a script to download scripts for vim directly from
> the +AD4 +AD4 www.vim.org site.
> +AD4 +AD4 Please find a link to the same :
> +AD4 +AD4
> http://blog.amit-agarwal.co.in/2011/03/09/all-in-one-solution-for-all-the-
> s +AD4 +AD4 cripts-of-vim-from-vim-org/
> +AD4 +AD4
> +AD4 +AD4 I would like to put that on www.vim.org site, if that is
> possible. +AD4 +AD4 Please help me with your comments and reviews and if
> you think this will +AD4 +AD4 be helpful for the vim users.

signature.asc
Reply all
Reply to author
Forward
0 new messages