Skip to content

%specialDef modifier does not like new lines #4030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mbertucci47 opened this issue Mar 22, 2025 · 1 comment
Open

%specialDef modifier does not like new lines #4030

mbertucci47 opened this issue Mar 22, 2025 · 1 comment

Comments

@mbertucci47
Copy link
Contributor

Environment

  • TeXstudio: 4.8.6
  • Qt: 6.8.2
  • OS: Windows 11
  • TeX distribution: N/A

Expected behavior

It shouldn't matter if a label-generating command has its argument on a new line.

Actual behavior

This is true for commands in LaTeX's label/ref namespace (so #l and #r in cwls) but not for %specialDef arguments.

How to reproduce

Here's an example showing the difference.

Image

# testpkg.cwl
\newvalue{myvalue%specialDef}{text}#s#%myvalue
\usevalue{myvalue%special}
\documentclass{article}
\usepackage{testpkg}

\begin{document}

% good
\newvalue{foo}{blub blub}
\usevalue{foo}

% bad
\newvalue
  {baz}{blub blub}
\usevalue{baz}

% good
\label{foo}
\ref{foo}

% good
\label
  {baz}
\ref{baz}

\end{document}
@mbertucci47
Copy link
Contributor Author

I'd like to add some more reasoning for why this is needed. Currently the glossaries and glossaries-extra bundles' cwls use the label/ref namespace, e.g. glossaries.cwl contains lines like

\newglossaryentry{label}{keyvals}#l

and

\gls{label}#r

However these commands do not actually use the \label/\ref namespace. The completion files were written this way out of convenience (before my time) but this results in pollution of the autocompleter for both \gls and \ref, among all the other affected commands. This could be fixed with %specialDef, something like

\newglossaryentry{gls-label%specialDef}{keyvals}#s#%gls-label

and

\gls{gls-label%special}

But the glossaries documentation consistently adds new lines after commands like \newglossaryentry. For example in glossaries-user-example001.tex you find

\newglossaryentry
{pi}% label
 {% definition:
 name={\ensuremath{\pi}},
 description={Archimedes' Constant}
} 
 \newglossaryentry
 {distance}% label
 {% definition:
 name={distance},
 description={the length between two points},
 symbol={m}
}

which does not add pi and distance to the gls-label namespace because of the bug reported above. (Ideally there would also be highlighting like for \label/\ref, but that's a separate issue.) So while a user could just write it as

\newglossaryentry{pi}% label
 {% definition:
 name={\ensuremath{\pi}},
 description={Archimedes' Constant}
} 

to make the completer work, I think it makes sense to support allowed TeX syntax that is explicitly used in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants