You can use a key=value interface that comes with that feature built in (I'd recommend expkv, but I'm its author... Other packages that have some expansion-control support built in are pgfkeys and options. Adding a wrapper around an existing macro that uses other key=value parsers is easiest with expkv.).
Unfortunately you want to use it for an existing macro that already uses another key=value interface, so we have to augment this one a bit (similar to @egreg's answer, but much simpler here). To do so we use \ekvparse (it'll apply the rules described below), and rebuild the key=value list afterwards with two auxiliary macros (\xincludepdf@k and \xincludepdf@kv in the following).
expkv provides a mechanism to specify expansions of key-values in a simple way. Just prefix your key with <rules>: (including the space after the colon) and the rules will get executed (in a key=value-pair the rules apply to value, if no =value was given they apply to the key). The following rules are built in (in the 2023-01-23 release):
o expand the value once
e fully expand the value using \expanded
c build a macro from the provided value (using \csname)
f expand the value until an unexpandable token is hit (if that's a space the space is removed)
V the value should be a single token, expands that token to the value (if it's a macro this is in effect o, if it's a register will result in that register's contents)
v like doing c and V (but different result if the resulting macro was undefined)
s strips one set of surrounding spaces and (if afterwards around everything) braces
b adds one set of braces around the value
p{<stuff>} places <stuff> before the value
P{<stuff>} places <stuff> after the value
g gobbles the first token or brace-group of value
\r reinsert the result of all expansions as additional key=value input
\key{<rules>} in a key=value pair apply to the key instead of the value
R same as V\r
r same as v\r
Multiple rules are consecutively applied from left to right, exception to this is \r that'll always apply after all other rules are processed.
For this use case we only need the o-rule (or could use the V-rule instead).
\documentclass{article}
\usepackage{pdfpages}
\usepackage{expkv}
\newcommand{\myargval}{1-3}
\makeatletter
\newcommand\xincludepdf[2][]
{%
\expandafter\includepdf
% inner \expanded fully expands \ekvparse,
% outer \expanded fully expands all \xincludepdf@k(v)
\expanded{\expanded{[\ekvparse\xincludepdf@k\xincludepdf@kv{#1}]}}%
{#2}%
}
% needs to protect against the outer \expanded, so uses \unexpanded (we don't
% want to expand more than the explicitly stated rules need)
\newcommand\xincludepdf@k[1]{,\unexpanded{#1}}
% the space between the = and the value make this more robust for most key=value
% parsers
\newcommand\xincludepdf@kv[2]{,\unexpanded{#1= {#2}}}
\makeatother
\begin{document}
\includepdf[pages=1-3, clip]{example-image-duck.pdf}
% o: means expand the value once, the space after the colon is mandatory
\xincludepdf[o: pages=\myargval, clip]{example-image-duck.pdf}
\end{document}
The \ekvparse doesn't need to know any of the keys of \includepdf, it'll just handle your requested expansion, every other parsing is handled by \includepdf itself, that'll complain if it encounters an unknown key.
\edef\temp{\noexpand\includepdf[pages=\myargval, clip]{example.pdf}}– Symbol 1 Apr 04 '17 at 21:57\edef\temp{\noexpand\includepdf[pages=\myargval, clip]{example.pdf}}\temp– Werner Apr 04 '17 at 22:08