# Just Launched: You can now import projects and releases from Google Code onto SourceForge

We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps.

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

None
open
nobody
None
1
2013-09-18
2013-09-10
Denis Bitouzé
No
1 up votes | 0 down votes | 100%
27 comments

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 3 > >> (Page 1 of 3)
• Ticket moved from /p/texstudio/bugs/807/

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

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

• 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.
% or % (to inserted
selected/translated text from the cwl), so % 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

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

• 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
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.

• 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é
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
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
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}

1 2 3 > >> (Page 1 of 3)