Loading ...
Sorry, an error occurred while loading the content.

Re: extracting tags like vim help

Expand Messages
  • Javier Mediavilla Vegas
    Hi, Maybe I messup things. I want to extract tags in my documents. Tags are present in the format the vim help files are. Example *tag1* *tag2* Here, there is
    Message 1 of 7 , Jul 10, 2013
    • 0 Attachment
      Hi,
      Maybe I messup things.
      I want to extract tags in my documents. Tags are present in the format the vim help files are.

      Example
      *tag1* *tag2*

      Here, there is two options to extract the tags and I have tested both of them.
      1. :helptags. It is a vim built-in function to extract the tags but only works for ".txt" and ".??x" file extensions.
      My files do not have that extension so I can't use it. I have searched for an option to change but I haven't found it.

      2. ctags. It does not have language support for vim help. It does vim language but It is for vim script. I have created an extension to the language with this content (I call my new language MAN)

      --langdef=MAN
      --language-force=MAN
      --regex-MAN=/\*([^\.\*][^\*]*)\*/\1/

      This works fine. Extract the tags inside starts. But there is a problem with several tags in the same line. For this issue I put the C example. Not because I want to use ctags to extract C tags but because ctags can extract several C tags in the same line.

      I use linux and exuberant ctags 5.9.

      Regards,
      Javier

      El miércoles, 10 de julio de 2013 16:10:16 UTC+2, Tony Mechelynck escribió:
      > On 10/07/13 15:33, Javier Mediavilla Vegas wrote:
      >
      > > Hi,
      >
      > > I want to extrack tags from files like :helptags does. The problem is that :helptags can only work with .txt and .??x files. I want to do it for a file with any file extension.
      >
      > > I have tried with ctags and defining my own language extension. Nevertheless, when two tags are in the same line, ctags only matches the first one.
      >
      > >
      >
      > > Example:
      >
      > > *E101* *E102*
      >
      > >
      >
      > > ctags will extract "E101" without extracting E102. I think this should be able to be done with ctags because in C language you can define two functions in the same line
      >
      > >
      >
      > > Example:
      >
      > > int add(void){return 5;} void some(void){}
      >
      > >
      >
      > > and ctags extract both of them althouth they are in the same line.
      >
      > >
      >
      > > The last change I take into account is to modify "helptags" function in the source code, that has ".txt" and "??x" files hardcoded.
      >
      > >
      >
      > > Any idea how to achieve this without touching source code?
      >
      > >
      >
      > > Thanks in advance,
      >
      > > Javier.
      >
      > >
      >
      >
      >
      > To use tags, you need to have a tags file containing the proper
      >
      > information. For C and a number of other languages, Exuberant Ctags can
      >
      > do it. I notice the following paragraph near the end of the manpage for
      >
      > that particular ctags program:
      >
      >
      >
      > Credit is also due Bram Moolenaar <Bram@...>, the author of vim, who
      >
      > has devoted so much of his time and energy both to developing the editor
      >
      > as a service to others, and to helping the orphans of Uganda.
      >
      >
      >
      > Just program as you normally would, then run Exuberant Ctags on your source.
      >
      >
      >
      > For Vim helpfiles, Vim can also generate the tags file itself (see :help
      >
      > :helptags). If you want to write documentation in any filetype that
      >
      > suits your fancy, and still use |bars| and *stars* as in Vim
      >
      > documentation, you may have to give appropriate options to Exuberant
      >
      > Ctags to tell it that "these files are Vim helpfiles even though their
      >
      > names don't end in .txt". If you didn't (yet) succeed at it, maybe
      >
      > there's a parameter you missed. If you have a Unix-like (including
      >
      > Linux, Cygwin, and, I think, Mac OSX) version of Exuberant Ctags, check
      >
      > its manpage (and, first, run "ctags --version": if it is Exuberant
      >
      > Ctags, it will proudly tell you).
      >
      >
      >
      >
      >
      > Best regards,
      >
      > Tony.
      >
      > --
      >
      > Reality is a cop-out for people who can't handle drugs.

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Charles Campbell
      ... You can do it with helptags, if you write some script. * move your help file to same YOURFILE.txt * apply helptags * move YOURFILE.txt back to YOURFILE.MAN
      Message 2 of 7 , Jul 10, 2013
      • 0 Attachment
        Javier Mediavilla Vegas wrote:
        > Hi,
        > Maybe I messup things.
        > I want to extract tags in my documents. Tags are present in the format the vim help files are.
        >
        > Example
        > *tag1* *tag2*
        >
        > Here, there is two options to extract the tags and I have tested both of them.
        > 1. :helptags. It is a vim built-in function to extract the tags but only works for ".txt" and ".??x" file extensions.
        > My files do not have that extension so I can't use it. I have searched for an option to change but I haven't found it.
        >
        You can do it with helptags, if you write some script.

        * move your help file to same YOURFILE.txt
        * apply helptags
        * move YOURFILE.txt back to YOURFILE.MAN
        * change the resulting <tags> file, using sed: sed -e
        's/\.txt/\.MAN/' tags

        You could also do the substitute with vim itself if you'd prefer.

        Regards,
        C Campbell

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Javier Mediavilla Vegas
        Hi, I thought about that but I have files with different file extensions. I.e. .1android, .1androidae so I would have to map each old file name to new file
        Message 3 of 7 , Jul 11, 2013
        • 0 Attachment
          Hi,
          I thought about that but I have files with different file extensions. I.e. .1android, .1androidae so I would have to map each old file name to new file name and rename, create tags, rename backwards and substitute with sed.

          Instead, I have modified vim source. I have changed the tags generation so
          * any file can be processed, regardless its extension
          * tags containing spaces are allowed and extracted.

          To do it, modify

          ex_cmds.c

          file and change
          in line 6446 (aprox), in the else branch add this
          // add english language when the extension is not recognize
          lang[0] = 'e';
          lang[1] = 'n';

          in line 6532 (aprox), delete the line
          STRCAT(NameBuff, ext);

          in line 6641 (aprox), delete
          *s == ' ' ||
          from the if branch inside the loop

          make to compile. And now, there it is a vim with :helptags that processes any file in a directory and allows tags with spaces (*tag space*)

          Regards.

          El miércoles, 10 de julio de 2013 22:38:53 UTC+2, Charles Campbell escribió:
          > Javier Mediavilla Vegas wrote:
          >
          > > Hi,
          >
          > > Maybe I messup things.
          >
          > > I want to extract tags in my documents. Tags are present in the format the vim help files are.
          >
          > >
          >
          > > Example
          >
          > > *tag1* *tag2*
          >
          > >
          >
          > > Here, there is two options to extract the tags and I have tested both of them.
          >
          > > 1. :helptags. It is a vim built-in function to extract the tags but only works for ".txt" and ".??x" file extensions.
          >
          > > My files do not have that extension so I can't use it. I have searched for an option to change but I haven't found it.
          >
          > >
          >
          > You can do it with helptags, if you write some script.
          >
          >
          >
          > * move your help file to same YOURFILE.txt
          >
          > * apply helptags
          >
          > * move YOURFILE.txt back to YOURFILE.MAN
          >
          > * change the resulting <tags> file, using sed: sed -e
          >
          > 's/\.txt/\.MAN/' tags
          >
          >
          >
          > You could also do the substitute with vim itself if you'd prefer.
          >
          >
          >
          > Regards,
          >
          > C Campbell

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Tony Mechelynck
          ... [...] You can add the .txt on top of whatever filename you have (e.g. Javier.Mediavilla.Vegas.1android → Javier.Mediavilla.Vegas.1android.txt), then run
          Message 4 of 7 , Jul 11, 2013
          • 0 Attachment
            On 11/07/13 19:39, Javier Mediavilla Vegas wrote:
            > Hi,
            > I thought about that but I have files with different file extensions. I.e. .1android, .1androidae so I would have to map each old file name to new file name and rename, create tags, rename backwards and substitute with sed.
            [...]

            You can add the .txt on top of whatever filename you have (e.g.
            Javier.Mediavilla.Vegas.1android →
            Javier.Mediavilla.Vegas.1android.txt), then run helptags (for all of
            them if within a single directory), then remove the extensions by a
            trivial modification of what Dr. Chip had proposed.


            Best regards,
            Tony.
            --
            I used to be an agnostic, but now I'm not so sure.


            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.