Saturday, March 5, 2016

Re: Packages

2016-03-05 22:32 GMT+03:00 Matthew Desjardins <desjardins.matthew@gmail.com>:
> On Saturday, March 5, 2016 at 2:00:48 PM UTC-5, LCD 47 wrote:
>> [...]
>> Tangentially related again: since these latest versions have been
>> pathogen slayers (like it or not, people are thinking about them that
>> way :)), pathogen has one more useful feature, the :Helptags command.
>> It runs :helptags in the directories in runtimepath. Perhaps add a
>> :packhelptags[!] that does the same thing for packages (with the bang
>> version forcing update of help for disabled plugins)?
>>
>> /lcd
>
> Well that's really easy to implement in vimscript, something like:
>
> for path in split(&packpath, ',')

Do not use `split(&packpath, ',')`, comma may be escaped. Better use
either long regex (may be seen in pathogen sources) or
`globpath(&packpath, '', 1, 1)`.

> for doc in split(glob(path . '/pack/**/doc'), '\n')

Again incorrect. `path` may contain special characters, so this should
be `fnameescape(path)`. Resulting directories may contain newlines, so
this should be `glob(fnameescape(path) . '/pack/**/doc', 0, 1)`
without `split()` at all. &wildignore may contain anything, so this
should be `glob(fnameescape(path) . '/pack/**/doc', 1, 1)`. `doc` may
be a file, so this should be `glob(fnameescape(path) .
'/pack/**/doc/', 1, 1)`

`fnameescape()` [does not work correctly on Windows][1], so this
should be `globpath(&packpath, 'pack/**/doc/', 1, 1)` in place of two
nested cycles.

> execute 'helptags' doc

Resulting `doc` may contain special characters, so this should be
`fnameescape(doc)`.

I guess you now see why built-in solution is needed: I found *six*
ways to break code that has only five lines. Solution should not
necessary be a built-in command, but at least autoload function
shipped with Vim, or you will see 100500 incorrect implementations
scattered all over the internet if users will have to write this
themselves.

[1]: https://github.com/vim/vim/issues/541

> endfor
> endfor
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment