Menu

#541 Citation commands in .cwl files apply only to last argument

None
open
nobody
None
1
2014-09-28
2013-09-10
No

Currently, citation commands in .cwl files are stipulated with the
"c" classifier, for instance:

\cite{bibid}#c

and that works pretty well: in the completion list, there are as
many \cite{...} commands as bibliographic entries are knows by TXS,
and in each of them (except the first one), the "bibid" argument is
replaced by a bibliographic entry identifier:

\cite{bibid}
\cite{knuth63}
\cite{knuth81}
\cite{knuth84}
...

But there are commands behaving like citation commands (they need a
bibliographic entry identifier) that do have many mandatory
arguments, for instance the commands from the csquotes package. One
of them is e.g.:

\textcquote{bibid}{text}

and, if the csquotes.cwl file contains:

\textcquote{bibid}{text}#c

that's the last argument which is replaced by the bibliographic
entry identifier:

\textcquote{bibid}{text}
\textcquote{bibid}{knuth63}
\textcquote{bibid}{knuth81}
\textcquote{bibid}{knuth84}
...

This is not the expected behavior... Unfortunately

\textcquote{bibid}#c{text}

doesn't work.

Hence, it would be nice to extend the .cwl machinery in order to be
able to specify which argument of a command has to behave "as
citation command". This would probably need to apply to some other
classifications as well (labels, graphics, references, ...)

Discussion

1 2 > >> (Page 1 of 2)
  • Benito van der Zander

    Ticket moved from /p/texstudio/bugs/807/

     
  • Benito van der Zander

    Perhaps this feature could be added to the extended placeholder options.

    Does not seem to be documented, but you can write e.g. %<text%:select%> or %<text%:translatable%> (to inserted selected/translated text from the cwl), so %<text%:cite%> would fit

     
  • Denis Bitouzé

    Denis Bitouzé - 2013-09-10

    Le mardi 10/09/13 à 16h30,
    "Benito van der Zander" benibela@users.sf.net a écrit :

    Perhaps this feature could be added to the extended placeholder
    options.

    Would be nice.

    Does not seem to be documented, but you can write e.g.
    %<text%:select%> or %<text%:translatable%> (to inserted
    selected/translated text from the cwl), so %<text%:cite%> would
    fit

    I tried with:

    \foo{%<bibid%:cite%>}{%<text%>}
    \bar{%<bibid%:cite%>}{text}
    

    But that doesn't work (as more or less expected). With:

    \foo{%<bibid%:cite%>}{%<text%>}#c
    \bar{%<bibid%:cite%>}{text}#c
    

    the %<bibid%:cite%> argument is indeed replaced by the bib entries
    keys: nice! But everything after it doesn't appear:

    \foo{bibid}{text}
    \foo{knuth63}
    \foo{knuth81}
    \foo{knuth84}
    ...
    

    whereas the expected behavior would be:

    \foo{bibid}{text}
    \foo{knuth63}{text}
    \foo{knuth81}{text}
    \foo{knuth84}{text}
    ...
    

    --
    Denis

     
  • Benito van der Zander

    Ofc it is not working, %:cite was just an idea to implement, not something that already was implemented...

     
  • Denis Bitouzé

    Denis Bitouzé - 2013-09-10

    Le mardi 10/09/13 à 20h13,
    "Benito van der Zander" benibela@users.sf.net a écrit :

    Ofc it is not working, %:cite was just an idea to implement, not
    something that already was implemented...

    Ah, okay, sorry.

    Denis

     
  • Tim Hoffmann

    Tim Hoffmann - 2013-09-10

    The current cwl format has evolved from the simpler kile-cwl format which was originally only intended for completion and not for encoding the semantics of commands. Before trying to hack in additionally stuff we should reflect if the present format is still the right way to go. The \cmd#something format maintained compatibility with kile due to the comment character. I suppose backward compatibility is already gone with the %acrobatics.

    There are at least two shortcomings of the cwl format:

    • It is not possible to address mutiple options. E.g. for \myfiginsert{label}{file} it is not possible to specifiy the first argument as label and the second one as file.

    • One cannot handle arguments like enviroments. E.g. the mhchem provides a commands \ce{} for typesetting chemical formulae. The argument accepts math commands, so it should be highlighted like a math environment.

    • Probably more.

     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-11

    the problem is not within the cwl format but with the implementation of the completer.
    right now it assumes, that the bibid is always the last element of a command.

    Furthermore, i like the cwl-format because it is easily undestandable and , what is more important, extendable.
    The user can at first just list the commands, he needs for his unknown package.
    Then he can add some further information , so that the syntax checker works better. Xml is hard to understand for an beginner ...

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-14

      I don't know if Tim had XML in mind but, if so, I agree the current cwl-format because is much easier understandable for a human than XML.

      But, whatever the underlying format used (even the 'easy' cwl one), it could be nice for TXS to provide a nice interface in order to easily create such files.

      One scenario I can imagine (though I haven't thought deeply about it): the user would write a plain text list of commands (and environments) ; then, clicking on a button would load them in a dialog box where, for each of them, the user would specify (by check boxes or similar easy to understand tools) what he's currently specifying in .cwl files.

       
      • Tim Hoffmann

        Tim Hoffmann - 2013-09-15

        Actually, I don't have a specific format in mind. The most important improvement required is the possibility to configure each argument of a command, on top of command-wide configuration. Whether this is inline or after the # or a completely different format like XML is a separate decision.

        Assume a hypothetical \citelink{cite}{url} command taking a reference as the first element, a url as the second argument. Additionally it is a rare command.

        Possible formats maintaining the current cwl structure would be:

        Inline:

        \citelink{cite%c}{url%U}#*
        

        Not sure if mixing text and formats is a good idea. There may also be %< %> and %| in there and then it becomes more and more unreadable.

        After # v1:

        \citelink{cite}{url}#*#c#u  // i.e. #<global>#<first_arg>#<second_arg>
        

        After # v2:

        \citelink{cite}{url}#*1:c2:u  // i.e. #<global>1:<first_arg>2:<second_arg>
        

        Then, the single chararcter specifiers are hard to remember and read. Why not use whole words?

        Personally, I don't like the asymmetry the escaping introduces to %< %>. %< >% or even better <% %> is much easier to read. This would just add a tiny bit of complexity to the parser. IMHO worth it. Alternative: Leave out the % and require escaping of <> when it is meant literally.

        As the above examples show, there is not necessarily a need for XML and the likes. But we should consider if there may be more things we want to store and if this is still possible in the above format. Otherwise we may hit limitations again.

         

        Last edit: Tim Hoffmann 2013-09-15
        • Tim Hoffmann

          Tim Hoffmann - 2013-10-09

          For completeness:
          It is also possible to bind certain argument names to a meaning, e.g.

          \citelink{cite}{url}
          

          where cite implicitly means a citation and url means a link.

          Advantage: This format is easily readable.
          Drawback: We directly bind the placeholder name to a functionality. The user cannot choose the placeholder name (also one might think of translated cwls, which would not be possible with this approach).

          Sideremark: Another requested feature is

          \import{path/}{filename}
          
           
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-16

    The solution right now is, that \citelink{bibid}{url}#C... assumes
    "bibid" the corresponding citation. This works as well with "url" tec
    without the need to define something complicated. Furthermore the
    abbreviation for citation would be identical whatever the command.

    Finally we don't have the code to realise the functionality so the
    discussion on the cwl-file is a little premature.

    Jan

    On 15.09.2013 22:05, Tim Hoffmann wrote:

    Actually, I don't have a specific format in mind. The most important
    improvement required is the possibility to configure each argument of a
    command, on top of command-wide configuration. Whether this is inline or
    after the # or a completely different format like XML is a separate
    decision.

    Assume a hypothetical |\citelink{cite}{url}| command taking a reference
    as the first element, a url as the second argument. Additionally it is a
    rare command.

    Possible formats maintaining the current cwl structure would be:

    Inline:

    \citelink{cite%c}{url%U}#*

    Not sure if mixing text and formats is a good idea. There may also be %<
    %> and %| in there and then it becomes more and more unreadable.

    \citelink{cite}{url}#*#c#u // i.e. #<global>#<first_arg>#<second_arg>

    \citelink{cite}{url}#*1:c2:u // i.e. #<global>1:<first_arg>2:<second_arg>

    Then, the single chararcter specifiers are hard to remember and read.
    Why not use whole words?

    Personally, I don't like the asymmetry the escaping introduces to |%<
    %>|. |%< >%| or even better |<% %>| is much easier to read. This would
    just add a tiny bit of complexity to the parser. IMHO worth it.
    Alternative: Leave out the % and require escaping of <> when it is meant
    literally.

    As the above examples show, there is not necessarily a need for XML and
    the likes. But we should consider if there may be more things we want to
    store and if this is still possible in the above format. Otherwise we
    may hit limitations again.


    [feature-requests:#541] Citation commands in .cwl files apply only to
    last argument

    Status: open
    Created: Tue Sep 10, 2013 03:30 PM UTC by Denis Bitouzé
    Last Updated: Wed Sep 11, 2013 08:03 PM UTC
    Owner: nobody

    Currently, citation commands in |.cwl| files are stipulated with the
    "c" classifier, for instance:

    \cite{bibid}#c

    and that works pretty well: in the completion list, there are as
    many |\cite{...}| commands as bibliographic entries are knows by TXS,
    and in each of them (except the first one), the "bibid" argument is
    replaced by a bibliographic entry identifier:

    \cite{bibid}
    \cite{knuth63}
    \cite{knuth81}
    \cite{knuth84}
    ...

    But there are commands behaving like citation commands (they need a
    bibliographic entry identifier) that do have many mandatory
    arguments, for instance the commands from the csquotes package. One
    of them is e.g.:

    \textcquote{bibid}{text}

    and, if the |csquotes.cwl| file contains:

    \textcquote{bibid}{text}#c

    that's the last argument which is replaced by the bibliographic
    entry identifier:

    \textcquote{bibid}{text}
    \textcquote{bibid}{knuth63}
    \textcquote{bibid}{knuth81}
    \textcquote{bibid}{knuth84}
    ...

    This is not the expected behavior... Unfortunately

    \textcquote{bibid}#c{text}

    doesn't work.

    Hence, it would be nice to extend the |.cwl| machinery in order to be
    able to specify which argument of a command has to behave "as
    citation command". This would probably need to apply to some other
    classifications as well (labels, graphics, references, ...)


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/texstudio/feature-requests/541/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     
  • Denis Bitouzé

    Denis Bitouzé - 2013-09-16

    Le lundi 16/09/13 à 17h49,
    "Jan Sundermeyer" jsundermeyer@users.sf.net a écrit :

    The solution right now is, that \citelink{bibid}{url}#C... assumes
    "bibid" the corresponding citation. This works as well with "url" tec
    without the need to define something complicated.

    Seems reasonable.

    Furthermore the
    abbreviation for citation would be identical whatever the command.

    OK. To be specified in the manual.

    Finally we don't have the code to realise the functionality so the
    discussion on the cwl-file is a little premature.

    OK.

    AFAICS, with 'C' marker, the '*' one is still ignored (with commit
    ead515). Do you expect make it work before 2.6.4 release?

    Best regards.

    --
    Denis

     

    Last edit: Tim Hoffmann 2013-09-17
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-16

    with 'C' marker, the '*' one is still ignored (with commit
    ead515). Do you expect make it work before 2.6.4 release?

    this functionality will not be implemented any time soon as it demands a
    complete different approach.

    On 16.09.2013 20:01, "Denis Bitouzé" wrote:

    Le lundi 16/09/13 à 17h49,
    "Jan Sundermeyer" jsundermeyer@users.sf.net
    jsundermeyer@users.sf.net a écrit :

    The solution right now is, that \citelink{bibid}{url}#C... assumes
    "bibid" the corresponding citation. This works as well with "url" tec
    without the need to define something complicated.
    

    Seems reasonable.

    Furthermore the
    abbreviation for citation would be identical whatever the command.
    

    OK. To be specified in the manual.

    Finally we don't have the code to realise the functionality so the
    discussion on the cwl-file is a little premature.
    

    OK.

    AFAICS, with 'C' marker, the '*' one is still ignored (with commit
    ead515). Do you expect make it work before 2.6.4 release?

    Best regards.
    

    Denis


    [feature-requests:#541] Citation commands in .cwl files apply only to
    last argument

    Status: open
    Created: Tue Sep 10, 2013 03:30 PM UTC by Denis Bitouzé
    Last Updated: Wed Sep 11, 2013 08:03 PM UTC
    Owner: nobody

    Currently, citation commands in |.cwl| files are stipulated with the
    "c" classifier, for instance:

    \cite{bibid}#c

    and that works pretty well: in the completion list, there are as
    many |\cite{...}| commands as bibliographic entries are knows by TXS,
    and in each of them (except the first one), the "bibid" argument is
    replaced by a bibliographic entry identifier:

    \cite{bibid}
    \cite{knuth63}
    \cite{knuth81}
    \cite{knuth84}
    ...

    But there are commands behaving like citation commands (they need a
    bibliographic entry identifier) that do have many mandatory
    arguments, for instance the commands from the csquotes package. One
    of them is e.g.:

    \textcquote{bibid}{text}

    and, if the |csquotes.cwl| file contains:

    \textcquote{bibid}{text}#c

    that's the last argument which is replaced by the bibliographic
    entry identifier:

    \textcquote{bibid}{text}
    \textcquote{bibid}{knuth63}
    \textcquote{bibid}{knuth81}
    \textcquote{bibid}{knuth84}
    ...

    This is not the expected behavior... Unfortunately

    \textcquote{bibid}#c{text}

    doesn't work.

    Hence, it would be nice to extend the |.cwl| machinery in order to be
    able to specify which argument of a command has to behave "as
    citation command". This would probably need to apply to some other
    classifications as well (labels, graphics, references, ...)


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/texstudio/feature-requests/541/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     
  • Denis Bitouzé

    Denis Bitouzé - 2013-09-16

    Le lundi 16/09/13 à 18h19,
    "Jan Sundermeyer" jsundermeyer@users.sf.net a écrit :

    this functionality will not be implemented any time soon as it
    demands a complete different approach.

    Ah, okay.

    So, because the completion window is currently too verbose, maybe should
    I myself drop (in fact comment) the unusual commands of the csquotes.cwl
    file. What is your opinion about this?
    --
    Denis

     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-16

    For now, i would let it be in there.

    On 16.09.2013 20:31, "Denis Bitouzé" wrote:

    Le lundi 16/09/13 à 18h19,
    "Jan Sundermeyer" jsundermeyer@users.sf.net
    jsundermeyer@users.sf.net a écrit :

    this functionality will not be implemented any time soon as it
    demands a complete different approach.
    

    Ah, okay.

    So, because the completion window is currently too verbose, maybe should
    I myself drop (in fact comment) the unusual commands of the csquotes.cwl
    file. What is your opinion about this?
    --
    Denis


    [feature-requests:#541] Citation commands in .cwl files apply only to
    last argument

    Status: open
    Created: Tue Sep 10, 2013 03:30 PM UTC by Denis Bitouzé
    Last Updated: Wed Sep 11, 2013 08:03 PM UTC
    Owner: nobody

    Currently, citation commands in |.cwl| files are stipulated with the
    "c" classifier, for instance:

    \cite{bibid}#c

    and that works pretty well: in the completion list, there are as
    many |\cite{...}| commands as bibliographic entries are knows by TXS,
    and in each of them (except the first one), the "bibid" argument is
    replaced by a bibliographic entry identifier:

    \cite{bibid}
    \cite{knuth63}
    \cite{knuth81}
    \cite{knuth84}
    ...

    But there are commands behaving like citation commands (they need a
    bibliographic entry identifier) that do have many mandatory
    arguments, for instance the commands from the csquotes package. One
    of them is e.g.:

    \textcquote{bibid}{text}

    and, if the |csquotes.cwl| file contains:

    \textcquote{bibid}{text}#c

    that's the last argument which is replaced by the bibliographic
    entry identifier:

    \textcquote{bibid}{text}
    \textcquote{bibid}{knuth63}
    \textcquote{bibid}{knuth81}
    \textcquote{bibid}{knuth84}
    ...

    This is not the expected behavior... Unfortunately

    \textcquote{bibid}#c{text}

    doesn't work.

    Hence, it would be nice to extend the |.cwl| machinery in order to be
    able to specify which argument of a command has to behave "as
    citation command". This would probably need to apply to some other
    classifications as well (labels, graphics, references, ...)


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/texstudio/feature-requests/541/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     
  • Denis Bitouzé

    Denis Bitouzé - 2013-09-17

    Le lundi 16/09/13 à 21h13,
    "Jan Sundermeyer" jsundermeyer@users.sf.net a écrit :

    For now, i would let it be in there.

    Well, e.g. for the \textcquote command, I get 16 variants for each
    bibliographic reference!

    For a document containing 6 bibliographic references, the completion
    list is shown here:

    http://gte.univ-littoral.fr/members/dbitouze/pub/latex/texstudio/completion-list/downloadFile/file/csquotes.pdf

    BTW, you can notice it isn't ordered as in the .cwl file. Indeed, for
    this command, the .cwl file contains:

    \textcquote{bibid}{text}#C
    \textcquote[prenote]{bibid}{text}#C
    \textcquote[][postnote]{bibid}{text}#C
    \textcquote[prenote][postnote]{bibid}{text}#C
    \textcquote{bibid}[punct]{text}#C
    \textcquote[prenote]{bibid}[punct]{text}#
    C
    \textcquote[][postnote]{bibid}[punct]{text}#C
    \textcquote[prenote][postnote]{bibid}[punct]{text}#
    C
    \textcquote{bibid}{text}#C
    \textcquote
    [prenote]{bibid}{text}#C
    \textcquote[][postnote]{bibid}{text}#C
    \textcquote
    [prenote][postnote]{bibid}{text}#C
    \textcquote{bibid}[punct]{text}#C
    \textcquote[prenote]{bibid}[punct]{text}#C
    \textcquote[][postnote]{bibid}[punct]{text}#C
    \textcquote[prenote][postnote]{bibid}[punct]{text}#C

    so one could expect the:

    \textcquote[prenote]{bibid}{text}

    variant coming just after the default:

    \textcquote{bibid}{text}

    but, in fact, it is located in the 8th part of the list...

    --
    Denis

     

    Last edit: Tim Hoffmann 2013-09-17
  • Tim Hoffmann

    Tim Hoffmann - 2013-09-17

    Under the above circumstances I'd recommend commenting them out. It's not really usable like this.

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-18

      OK, I'll commit an sanitized version.

      What about the order?

       
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-18

    txs sort the completion lists alphabetically (since otherwiese the reduction of visible elements is too complicated/slow)
    So, you can do nothing on the sort order.

    Furthermore, the user can edit completed texts as, so reduce the number of suggestions !

    \textcquote{bibid}{text}#C as the most used variant
    \textcquote[prenote][postnote]{bibid}{text}#C (or other) for completeness sake (and if that is not used that often it might be left away)

    You should leave out the other variants as they clutter the window and they don't really bring much more comfort for the user.

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-18

      You should leave out the other variants as they clutter the window and they don't really bring much more comfort for the user.

      Okay.

      Is the %<...%> feature working in commands with bibid field?

      For instance

      \foreignquote{%<language%>}{text}
      

      works well, but not:

      \foreigntextcquote{%<language%>}{bibid}{text}#C
      
       
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-18

    it should not be necessary to place any %< / %> as txs automatically places them for all command options.

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-18

      it should not be necessary to place any %< / %> as txs automatically places them for all command options.

      No, it doesn't work.

      Removing %<...%>:

      \foreigntextcquote{language}{bibid}{text}#C
      

      leads to a very odd behavior (the placeholders span the arguments, as shown in the joined image.

      And, with:

      \textcquote[prenote]{bibid}{text}#C
      

      prenote is not a placeholder.

       
  • Jan  Sundermeyer

    Jan Sundermeyer - 2013-09-18

    okay, that is a bug.
    as i don't have much time now, i will fix it next week.
    Keep in mind, that the C option is not yet fully functionalDenis Bitouzé denisbitouze@users.sf.net hat geschrieben:it should not be necessary to place any %< / %> as txs automatically places them for all command options.

    No, it doesn't work.

    Removing %<...%>:

    \foreigntextcquote{language}{bibid}{text}#C
    leads to a very odd behavior (the placeholders span the arguments, as shown in the joined image.

    And, with:

    \textcquote[prenote]{bibid}{text}#C
    prenote is not a placeholder.

    [feature-requests:#541] Citation commands in .cwl files apply only to last argument

    Status: open
    Created: Tue Sep 10, 2013 03:30 PM UTC by Denis Bitouzé
    Last Updated: Wed Sep 18, 2013 09:21 AM UTC
    Owner: nobody

    Currently, citation commands in .cwl files are stipulated with the
    "c" classifier, for instance:

    \cite{bibid}#c
    and that works pretty well: in the completion list, there are as
    many \cite{...} commands as bibliographic entries are knows by TXS,
    and in each of them (except the first one), the "bibid" argument is
    replaced by a bibliographic entry identifier:

    \cite{bibid}
    \cite{knuth63}
    \cite{knuth81}
    \cite{knuth84}
    ...
    But there are commands behaving like citation commands (they need a
    bibliographic entry identifier) that do have many mandatory
    arguments, for instance the commands from the csquotes package. One
    of them is e.g.:

    \textcquote{bibid}{text}
    and, if the csquotes.cwl file contains:

    \textcquote{bibid}{text}#c
    that's the last argument which is replaced by the bibliographic
    entry identifier:

    \textcquote{bibid}{text}
    \textcquote{bibid}{knuth63}
    \textcquote{bibid}{knuth81}
    \textcquote{bibid}{knuth84}
    ...
    This is not the expected behavior... Unfortunately

    \textcquote{bibid}#c{text}
    doesn't work.

    Hence, it would be nice to extend the .cwl machinery in order to be
    able to specify which argument of a command has to behave "as
    citation command". This would probably need to apply to some other
    classifications as well (labels, graphics, references, ...)

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/texstudio/feature-requests/541/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-18

      okay, that is a bug.
      as i don't have much time now, i will fix it next week.

      No problem.

      Keep in mind, that the C option is not yet fully functional

      Okay. I'll wait for your fix before sending a new .cwl file.

       
    • Denis Bitouzé

      Denis Bitouzé - 2013-09-20

      i will fix it next week.

      Despite commit #3241d1, I still get the completion trouble, as shown here with the joined csquotes.cwl file.

       
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel