#704 Highlight wrong keys of commands with known list f keys

None
closed
nobody
None
1
2014-08-19
2014-05-08
Denis Bitouzé
No

For commands subject to #keyvals/#endkeyvals in .cwl files, it would be nice for keys that are not in the corresponding list to be highlighted as wrong.

Why not extend this concept to values of keys that have limited list of values? For instance locale key of siunitx package has only UK, US, DE, FR and ZA as acceptable values.

Related

Feature Requests: #704

Discussion

  • implemented
    at the moment, graphicx.cwl is set,
    siuntix is just adapted for \SI a bit for testing, hence it is not comprehensive

     
    • Denis Bitouzé
      Denis Bitouzé
      2014-05-22

      implemented

      One of the drawback of this very nice feature (thanks again, Jan) is that some keys, coming from packages, are recommended to be passed at the
      \documentclass level, for instance the languages of the babel package:

      \documentclass[french,english]{article}
      % other packages
      \usepackage{babel}
      \begin{document}
      % Content
      \end{document}
      

      But, because they aren't keys coming from the class, they are highlighted as wrong.

      One could add the languages keys in all the class-xxx.cwl files or in the
      latex-document.cwl but I guess it is not the better method. Do you see
      a clever way to circumvent this problem?

       
      • Tim Hoffmann
        Tim Hoffmann
        2014-05-22

        I don't see a good way. Maybe it's best to deactivate the parameter
        check for classes. That way, the keyword arguments of the class can
        still be inserted via the completer, but any keyword is accepted (or
        more precisely none is marked wrong).

        Am 22.05.2014 21:47, schrieb "Denis Bitouzé" :

        implemented
        

        One of the drawback of this very nice feature (thanks again, Jan) is
        that some keys, coming from packages, are recommended to be passed at the
        |\documentclass| level, for instance the languages of the |babel| package:

        \documentclass[french,english]{article}
        % other packages
        \usepackage{babel}
        \begin{document}
        % Content
        \end{document}

        But, because they aren't keys coming from the class, they are
        highlighted as wrong.

        One could add the languages keys in all the |class-xxx.cwl| files or
        in the
        |latex-document.cwl| but I guess it is not the better method. Do you see
        a clever way to circumvent this problem?


        [feature-requests:#704]
        http://sourceforge.net/p/texstudio/feature-requests/704/ Highlight
        wrong keys of commands with known list f keys

        Status: closed
        Group:
        Created: Thu May 08, 2014 03:45 PM UTC by Denis Bitouzé
        Last Updated: Fri May 16, 2014 03:05 PM UTC
        Owner: nobody

        For commands subject to |#keyvals|/|#endkeyvals| in |.cwl| files, it
        would be nice for keys that are not in the corresponding list to be
        highlighted as wrong.

        Why not extend this concept to values of keys that have limited list
        of values? For instance |locale| key of |siunitx| package has only
        |UK|, |US|, |DE|, |FR| and |ZA| as acceptable values.


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

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

         

        Related

        Feature Requests: #704

    • status: open --> closed
    • Group: -->
     
  • Denis Bitouzé
    Denis Bitouzé
    2014-05-16

    implemented

    Thanks!

    I played a bit with it, especially with values of keys that have limited list of values: "To specify possible values for keys, add them after # e.g. mode=#text,math".

    That works nicely, except the commas between the "key=value"s are highlighted as wrong, at least in the case of the following .cwl file:

    # mode: yathesis.cls
    # denisbitouze, 16.05.2014
    #
    #include:class-book
    #include:latex-document
    [...]
    #keyvals:\documentclass
    mainlanguage=#french,english
    secnumdepth=#part,chapter,section,subsection,subsubsection,paragraph,subparagraph
    space=#single,onehalf,double
    chap-style=#Sonny,Lenny,Glenn,Conny,Rejne,Bjarne,PetersLenny,Bjornstrup,none
    nofrontcover#true,false
    sepcorpaffilfrench=
    sepcorpaffilenglish=
    version=#inprogress,inprogress*,submitted,submitted*,final,draft
    output=#screen,paper,paper*
    10pt
    11pt
    12pt
    leqno
    fleqn
    oneside
    #endkeyvals
    [...]
    

    (see attachment).

    Apart from that, two more features requests:

    1. The first entered key in the [...] optional argument doesn't open the completion popup: it seems that a leading comma is necessary for this popup to be open.
    2. Make the possible values for keys be displayed in the completion popup. For instance with the previous .cwl file where space keys has single, onehalf and double as possible values, typing spa could display:

      space=single
      space=onehalf
      space=double

     
    Attachments
  • Hi Denis,

    you are free to define any keys you want, e.g.

    keyvals:\documentclass

    mainlanguage=french
    mainlanguage=english

    Jan

     
    • Denis Bitouzé
      Denis Bitouzé
      2014-05-16

      you are free to define any keys you want, e.g.

      #keyvals:\documentclass
      mainlanguage=french
      mainlanguage=english
      [...]
      secnumdepth=part
      secnumdepth=chapter
      secnumdepth=section
      secnumdepth=subsection
      secnumdepth=subsubsection
      secnumdepth=paragraph
      secnumdepth=subparagraph
      space=single
      space=onehalf
      space=double
      [...]
      

      Wait, wait: a drawback is that the completion list will increase quickly.

      Another approach, maybe trickier to implement, would be the following:

      #keyvals:\documentclass
      mainlanguage=#french,english
      secnumdepth=#part,chapter,section,subsection,subsubsection,paragraph,subparagraph
      space=#single,onehalf,double
      [...]
      

      displays in the completion list only the keys:

      mainlanguage=
      secnumdepth=
      space=
      [...]
      

      and, once the list contains only one key, its possible values appear:

      mainlanguage=french
      mainlanguage=english
      
       
  • Denis Bitouzé
    Denis Bitouzé
    2014-05-16

    Hi Jan,

    indeed, you're right! The other syntax:

    space=#single,onehalf,double
    

    providing the same feature would be easier, though ;)

    What about my first feature request?

     
  • i will think about it.
    Problem is that you need a good indication when the completer is desired by the user. cursor position is insufficient, maybe after typing a few letters, the completer could pop-up but i have to check the logic whether that is (easily) possible.

     
  • Denis Bitouzé
    Denis Bitouzé
    2014-05-16

    Problem is that you need a good indication when the completer is desired by the user. cursor position is insufficient,

    Why not just after the opening squared bracket of the command's optional argument?

     
  • when exactly ? when the cursor is placed there ? (which would already be difficult to implement)
    So what would happen if the user moves the cursor through a line and happens to hit that spot ?

     
  • Denis Bitouzé
    Denis Bitouzé
    2014-05-16

    when exactly ? when the cursor is placed there ?

    No: just after the opening squared bracket is entered. This already automatically inserts the closing bracket after the cursor, so could be nice the completion popup is displayed if keys for the underlying macro are known.

     
  • but who enters that bracket by hand if the command can be completed ?

     
  • Denis Bitouzé
    Denis Bitouzé
    2014-05-16

    but who enters that bracket by hand if the command can be completed ?

    You're right, once again! :)

    Let's say the pop-up is displayed:

    • immediately,
    • after typing a few letters,

    depending if the bracket is entered by hand or not

     
  • Denis Bitouzé
    Denis Bitouzé
    2014-06-05

    It could be nice for the #keyvals/#endkeyvals feature to not be limited to optional arguments and to be extended to mandatory ones.

    For instance, hyperref package provides the \hypersetup macro whom mandatory argument is supposed to accept same options as \usepackage optional argument, as said page 4 of its documentation: "The options can be set either in the optional argument to the \usepackage command, or using the \hypersetup macro."