Nikolay Pavlov wrote:
> >> 2016-03-30 16:39 GMT+03:00 Ken Takata <[email protected]>:
> >> > Hi Bram,
> >> >
> >> > 2016/3/27 Sun 21:23:36 UTC+9 Bram Moolenaar wrote:
> >> >> The backticks work like bars, but highlight the text as a command. I
> >> >> started doing this a year ago, so there are still lots of commands in
> >> >> bars. The idea is to use backticks where possible.
> >> >
> >> > The usage of bars in the help is written in `:help bars`, but the usage
> >> > of backticks are not written, I think. Maybe it's better to mention
> >> > about
> >> > backticks.
> >>
> >> Also how about actually changing the meaning to “inline code block”?
> >> From that “quick :helpgrep” I see that backticks are used as “inline
> >> code block” in:
> >>
> >> 1. plugins like command-t, editorconfig, ag, pymode (though this one
> >> uses ``…`` inherited from rst I guess, but this is also highlighted,
> >> though excluding “outer” backticks), Bashka/vim_template, gutentags
> >> 2. change.txt: e.g. from “`:retab!`” <C-]> will not jump to `:retab`,
> >> though other backticks are mostly proper links
> >> 3. cmdline.txt: e.g. from “`:'<,'>`” it will not jump anywhere, though
> >> other backticks are also mostly links here
> >> 4. filetype.txt: all occurences mark shell commands
> >> 5. if_pyth.txt: almost all occurences mark Python code
> >> 6. pi_netrw.txt: all occurences mark shell or VimL commands
> >> 7. starting.txt: again commands with bangs, <C-]> does not jump
> >> 8. syntax.txt: 2 of 2 occurences did not mean links
> >> 9. version7.txt: I see things like “`str()`”: Python code again
> >>
> >> In any case allowing space inside backtick highlighted region is not
> >> going to change the ability of <C-]> to jump to a tag.
> >
> > The main concern was that when accepting any text between backticks,
> > including spaces, lines where two or more backticks appear are
> > unintentionally highlighted. I haven't tried to find out how many times
> > that happens. At least the `m command exist. If there are any such
> > places, how does one avoid the highlighting?
>
> I do not see any problems with the “`m” command, these commands help
> does not contain `…`. But usually such problem is solved by simply
> requiring that “inline code block” is
>
> \v%(^|\s|\()@1<=
> \`\S@1=[^`]{-}\S@1<=\`
> %($|\s|%(\.{1,3}|[!?]{1,2})%(\ \ |$)|\,%(\ |$)|\))@5=
>
> (i.e. backtick that starts inline code block is either preceded by a
> line start, whitespace or opening parenthesis and is followed by
> either line end, whitespace, sentence end (i.e. punctuation that ends
> sentence (., .., ..., !, !?, ?!, !!, ??) followed by either line end
> or two spaces), comma followed by a space or line end, or closing
> parenthesis; code in the inline code block must start and end with a
> non-whitespace character).
>
> I do not see any problems with “`m” or “m`”, but in my documentation
> you may find examples of “`foo'”: i.e. backtick closed by a quote
> (also “``foo''” in NERD commenter documentation: like my variant, but
> doubled), such complex regex should prevent these from causing
> problems (though specifically against them one needs only “code … must
> start and end with a non-whitespace …” condition).
That's a very complex regexp. I always try to avoid things like @1<=,
because it makes the pattern slow.
I tried this:
syn match helpCommand
"\(^\|[^a-z]\)\zs`[^`]\+`\ze\([^a-z]\|$\)"hs=s+1,he=e-1 contains=helpBacktick
So far I found one place where it kicks in where it should not:
:e `ls #` :e {files matching "?readme?"}
So this is using backticks in a shell command. I think your regexp
doesn't do better.
I can avoid this specific one by not accepting a Tab after the match:
syn match helpCommand
"\(^\|[^a-z]\)\zs`[^`]\+`\ze\([^a-z\t]\|$\)"hs=s+1,he=e-1 contains=helpBacktick
This assumes an inline command would not have a Tab after it. For
consistency perhaps also check for no Tab before the match?
This is another false match:
character. Even when you move around in the file `" and `. will take you to
So add "." to the character range. I found a few more, so now I have:
syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick
syn match helpCommand
"\(^\|[^a-z"[]\)\zs`[^`]\+`\ze\([^a-z\t."']\|$\)"hs=s+1,he=e-1
contains=helpBacktick
I used this to find help with two backticks:
:helpgrep `.* .*`
--
hundred-and-one symptoms of being an internet addict:
177. You log off of your system because it's time to go to work.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.