Deactivate protrusion for active character «

Is ist possible to deactivate microtype’s protrusion for certain characters only? I’m trying to make «#1» a shortcut for \fbox{#1} but it won’t work unless I deactivate protrusion completly.

% !TeX program = lualatex
\documentclass[ngerman]{article}

\usepackage{fontspec,unicode-math}
\usepackage[
%   protrusion = false,
]{microtype}

\catcode« = \active
\def«#1»{
\fbox{#1}
}

\begin{document}
Test «Test» \fbox{Test}
\end{document}


I won’t need the guillemets character in the output.

You just get an annoying warning, but the active character works.

In order to remove the warning, delay the activation.

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{fontspec,unicode-math}
\usepackage[
%   protrusion = false,
]{microtype}

\protected\def\activeguill#1»{%
\fbox{#1}%
}
\AtBeginDocument{%
\begingroup\lccode~=« \lowercase{\endgroup\let~}\activeguill
\catcode«=\active
}

\begin{document}

Test «Test» \fbox{Test}

Test \fbox{Test} \fbox{Test}

\end{document}


The output would be the same with your code, though (provided spurious spaces are removed).

• With the code in my post I get an error not a warning (arg has extra }) … and the spaces are there because I normally use expl3 syntax, and forgot to add %` here … – Tobi May 20 '17 at 9:39
• @Tobi I have delete my post. There is the superlative egreg. :-). +1 also for egreg. – Sebastiano May 20 '17 at 10:03