Skip to content
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

Behavior of .add code used on a non-existent key #1285

Open
muzimuzhi opened this issue Oct 5, 2023 · 0 comments
Open

Behavior of .add code used on a non-existent key #1285

muzimuzhi opened this issue Oct 5, 2023 · 0 comments
Labels

Comments

@muzimuzhi
Copy link
Member

Brief outline of the bug

When used on a non-existent key, .add code uses \pgfkeyssetvalue{<full key>}{#1}, not empty, as the initial key body. Is this behavior on purpose/relied on by other codes?

It was introduced in acf16c2 (worked on bug #250, 2013-07-15), in resolving #249. Before acf16c2, empty was used as the initial key body.

The pgfmanual only says .add code is one of handlers to modify existing keys.

There are also handlers for modifying existing keys.
\begin{handler}{{.add code}|=|\marg{prefix code}\marg{append code}}
This handler adds code to an existing key. The \meta{prefix code} is added
to the code stored in \meta{key}|/.@cmd| at the beginning, the \meta{append
code} is added to this code at the end. Either can be empty. The argument
list of \meta{code} cannot be changed using this handler. Note that both
\meta{prefix code} and \meta{append code} may contain parameters like |#2|.

Minimal working example (MWE)

\documentclass{article}
\usepackage{pgfkeys}

\pgfkeys{
  % executes \@namedef{pgfk@/a/.@cmd}#1\pgfeov{}
  a/.code={},
  % executes \@namedef{pgfk@/a/.@cmd}#1\pgfeov{<pre a><post a>}
  a/.add code={<pre a>}{<post a>},
  % executes \@namedef{pgfk@/b/.@cmd}#1\pgfeov{<pre b>\pgfkeyssetvalue{/b}{#1}<post b>}
  % why the "\pgfkeyssetvalue{/b}{#1}" part?
  b/.add code={<pre b>}{<post b>},
  a/.show code,
  b/.show code
}

\begin{document}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant