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

Re: RDF manifests highlighted as error from line 2 to the end

Expand Messages
  • Bram Moolenaar
    ... I think it would work to detect a .rdf file as redif after scripts.vim has been used to check for XML. ... Deleting everything is a bit dangerous. Since a
    Message 1 of 7 , Apr 7, 2013
    • 0 Attachment
      Tony Mechelynck wrote:

      > >> When I try to view a *.rdf file, for instance the attached install.rdf
      > >> from the ChatZilla extension to Firefox or SeaMonkey, Vim sets "redif"
      > >> filetype and displays everything after the XML header in black on red
      > >> (highlight group redifIncorrectBeginningOfFile, linking to Error). In
      > >> order to clear the error (and since there is no specific syntax for
      > >> RDF/XML), I have to set the filetype manually to XML.
      > >>
      > >> Strangely enough, there is no syntax script for redif: all syntax
      > >> commands for that syntax are in the filetype-plugin, which is incorrect
      > >> procedure by Vim standards. In fact, AFAICT,
      > >> $VIMRUNTIME/ftplugin/redif.vim is actually a syntax script, not a
      > >> filetype-plugin, and ought to be in syntax/ instead of in ftplugin/.
      > >
      > > Sorry, somehow I managed to put the file in the wrong directory.
      > >
      > >> What should I do? What should other users like me do in order to have
      > >> their RDF files correctly identified as XML-serialized Resource
      > >> Description Framework manifests and not as whatever "redif" might be?
      > >
      > > Apparently your .rdf file is not redif. So we need a better way to
      > > detect the filetype.
      > >
      > > It appears that redif uses # comments, while your .rdf file looks like
      > > XML, thus lots of <>. That could be used.
      > >
      > Yes, RDF/XML (as described in the Wikipedia and W3C links in my previous
      > post) can be regarded as a subtype of XML. In particular it starts with
      > <?xml (a UTF-8 BOM might be acceptable before that, I haven't boned up
      > that far on the standard) and it uses the same <!-- comments --> as XML
      > et al. The corresponding MIME type is application/rdf+xml

      I think it would work to detect a .rdf file as redif after scripts.vim
      has been used to check for XML.

      > Thanks Bram! After the update, the file is recognised as ft=xml, which
      > is the best we can do AFAIK.
      >
      > BTW, it seems that "make install" over an existing installation of Vim
      > doesn't remove files which have been removed (or moved away) on
      > Mercurial. I've deleted $VIMRUNTIME/ftplugin/redif.vim manually. (The
      > script still exists as $VIMRUNTIME/syntax/redif.vim)
      >
      > Maybe one of these days I should do
      > rm -Rvf /usr/local/share/vim/vim73
      > make install

      Deleting everything is a bit dangerous. Since a mistake like this would
      happen very infrequently let's just leave it.

      --
      Never eat yellow snow.

      /// Bram Moolenaar -- Bram@... -- 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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... OK, now I have this at line 2566 of filetype.vim: ReDIF Only used when the .rdf file was not detected to be XML. au BufRead,BufNewFile *.rdf call
      Message 2 of 7 , Apr 8, 2013
      • 0 Attachment
        Axel Castellane wrote:

        > Sorry for the late answer. redif files do have comments that start with
        > /^#/, but they are likely to have no comment at all since they are very
        > self-explicit...
        >
        > However, any redif file must have a name in *.rdf, and must also have its
        > first line, except for potential comments, in /^\ctemplate-type:/.
        > Something like
        >
        > let lnum = 1
        > while lnum <= 5
        > let s:line =getline(lnum)
        > if s:line =~ "^\ctemplate-type:"
        > setf redif
        > endif
        > let lnum = lnum + 1
        > endwhile
        >
        > that happens inside an autocommand for *.rdf files is most likely to catch
        > 99% of redif files. I hope it helps.

        OK, now I have this at line 2566 of filetype.vim:

        " ReDIF
        " Only used when the .rdf file was not detected to be XML.
        au BufRead,BufNewFile *.rdf call s:Redif()
        func! s:Redif()
        let lnum = 1
        while lnum <= 5 && lnum < line('$')
        if getline(lnum) =~ "^\ctemplate-type:"
        setf redif
        return
        endif
        let lnum = lnum + 1
        endwhile
        endfunc


        > Finally, I attached a new version of the syntax file.

        I'll include it, thanks.

        --
        hundred-and-one symptoms of being an internet addict:
        136. You decide to stay in a low-paying job teaching just for the
        free Internet access.

        /// Bram Moolenaar -- Bram@... -- 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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Tony Mechelynck
        ... This is an unhappy choice, since the W3C recommends *.rdf (with an all-lowercase extension) for RDF/XML files, see
        Message 3 of 7 , Apr 8, 2013
        • 0 Attachment
          On 08/04/13 05:34, Axel Castellane wrote:
          > Sorry for the late answer. redif files do have comments that start with
          > /^#/, but they are likely to have no comment at all since they are very
          > self-explicit...
          >
          > However, any redif file must have a name in *.rdf, and must also have [...]

          This is an unhappy choice, since the W3C recommends *.rdf (with an
          all-lowercase extension) for RDF/XML files, see
          http://www.w3.org/TR/rdf-syntax-grammar/#section-MIME-Type

          However, ReDIF seems rather confidential: I could find nothing about it
          on Wikipedia (in any of English, French and German, except as the
          reserve force of former Turkish and Egyptian armies), and a Google
          search yielded only
          http://econpapers.repec.org/paper/rpcrdfdoc/redif.htm which resends to
          http://openlib.org/acmes/root/docu/redif_1.html — a document dated
          2007-06-01, with no Table of Contents, where the string "rdf" does not
          appear at all (in any character case), and where it is said that the
          default charset for ReDIF files is Windows-1252 (!), though UTF-8 is
          recommended and must be heralded by a BOM.

          Couldn't RePEc and the W3C agree on file extensions? Isn't there a
          central place where extensions and MIME types (application/rdf+xml, in
          the case of RDF/XML files) are registered? Or do organizations grab any
          three-letter group that suits their fancy, without checking if someone
          somewhere uses the same file extension for a different purpose?


          Best regards,
          Tony.
          --
          Learned men are the cisterns of knowledge, not the fountainheads.

          --
          --
          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 vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Tony Mechelynck
          ... !!! And from what I read in that HTML page, it seemed to me that to them, the existence of non-Windows operating systems is some quaint feature of out-of
          Message 4 of 7 , Apr 9, 2013
          • 0 Attachment
            On 09/04/13 04:55, Axel Castellane wrote:
            > Sorry Tony, but I believe that RePEc (the organization that uses ReDIF
            > files) does not understand so much about the consistency of file
            > extensions and everything related to the Internet. It is not its area of
            > expertise. Its main focus is economics. Formatted text and Internet are
            > just convenient tools for classifying the papers, authors, etc. and
            > doing some statistics. I think that at the time they started their
            > service, they did not even know that another type of files had a .rdf
            > extension... Most probably, they did not even know about W3C.

            !!!
            And from what I read in that HTML page, it seemed to me that to them,
            the existence of non-Windows operating systems is some quaint feature of
            out-of the way places… They know about it, but only in passing… Or maybe
            I am overgeneralizing.

            >
            > By the way, RePEc is the largest database of working papers of
            > economics. It also cross-registers references about most of the journals
            > of economic literature. It is referenced on Google Scholar. It publishes
            > a ranking of authors which is used a lot in the job market of
            > researchers in economics. In a word, it is quite big. To browse the
            > statistics of any paper, article, author or institution, go on
            > http://ideas.repec.org/. It is not really "confidential". I would say it
            > is more like a niche, which does not attract so many wikipedia
            > contributors, hence its low visibility on Internet, I guess.

            OK, let's call it a niche; it might be of interest to my nephew who has,
            IIUC, an economy degree, but to me, who studied math, worked at various
            times as a computer programmer (in COBOL and assembly language), a
            teacher (math/physics, to children ages 12 to 15) or a translator
            (English and Dutch into French), they could just as well be on another
            planet.

            >
            > I think the new filetype.vim is really highly unlikely to catch anything
            > else than a ReDIF file, so it is not a big deal that it uses a wrong
            > file extension.

            Good. IIUC, with the new filetype.vim, *.rdf files which look like XML
            will be detected as filetype=xml, those which have a redif header will
            be detected as filetype=redif, and if a file comes about which is
            neither, its filetype won't be set unless it fits some other filetype's
            criteria.

            >
            > Finally, I think that the file extension cannot be changed, because the
            > script that reads ReDIF files silently ignores all other files, and I
            > have heard that the person who programmed it (in Perl...) some time ago
            > is not maintaining it anymore...

            Oh, I'm sure there still exist some working programmers with a knowledge
            of Perl, the problem would be what to decide and how to implement it,
            without throwing wrenches this way and that into all the wheels of the
            RePEc libraries. I suppose we will have to leave it unchanged, with name
            collision and all, at least for the time being.


            Best regards,
            Tony.
            --
            Feminists say 60 percent of the country's wealth is in the hands of
            women. They're letting men hold the other 40 percent because their
            handbags are full.
            -- Earl Wilson

            --
            --
            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 vim_dev+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.