Hello,

I've succeeded in simplifying the \spadop, etc. commands (see attachment).

As can be seen from the .tex file, there is no need to escape any
letter, but now \spadop would somehow work like \verb, i.e. not with braces.

These tricks allow also to get rid of the X versions of the commands:
\spadfunX, \spadfunFromX.

My next goal is to remove the "From" part from \spadopFrom.

I think I've two options as a new syntax for \spadopFrom{+}{Integer}:

1) \spadop`^$Integer`
2) \spadop`^`|Integer|

I'm more in favour of the first option, because it looks relatively
natural for a SPAD programmer and is shorter than the second, but it
would make $ somewhat special. I don't yet know whether I can program
code for (1), but I'll try.

\spadop`^$Integer` would only print ^. Similar as for HyperDoc, the type
is just there to have enough information to make ^ a hyperlink to the
right function definition (or rather it's ++ documentation).

Opinions?

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
\documentclass{article}
\usepackage{makeidx}
\makeindex

\usepackage{color}
\usepackage{xparse}
\NewDocumentCommand{\verbspadop}{v}{\textcolor{blue}{\texttt{#1}}}
\NewDocumentCommand{\verbspadfun}{v}{\textcolor{red}{\texttt{#1}}}
\NewDocumentCommand{\verbspadtype}{v}{\textcolor{magenta}{\textsf{#1}}}

\NewDocumentCommand{\textspadop}{m}{\textcolor{blue}{\texttt{#1}}}
\NewDocumentCommand{\textspadfun}{m}{\textcolor{red}{\textsf{#1}}}
\NewDocumentCommand{\textspadtype}{m}{\textcolor{magenta}{\textbf{#1}}}

\newif\ifinspadindex \inspadindexfalse
\def\spadexclamation{!}
\def\spadmid{|}

\makeatother
  \def\spadat{@}
  \def\spadindex#1#2{\index{#1@#2}}
\makeatletter

\begingroup
  % characters that must be escaped for makeindex
  \catcode`\!=\active \gdef!{\ifinspadindex"\fi\spadexclamation}
  \catcode`\|=\active \gdef|{\ifinspadindex"\fi\spadmid}
  \catcode`\@=\active \gdef@{\ifinspadindex"\fi\spadat}
\endgroup

\def\Xspadname#1#2{%
  \def\XXspadname##1#2{%
    \inspadindexfalse
    \csname textspad#1\endcsname{##1}%
    \inspadindextrue
    \spadindex{##1}{\expandafter\protect\csname verbspad#1\endcsname#2##1#2}
    \egroup}%
  \XXspadname}

\def\spadname#1{\bgroup \let\do\@makeother \dospecials
  \catcode`\!=\active
  \catcode`\|=\active
  \catcode`\@=\active
  \Xspadname{#1}}

\def\spadop{\spadname{op}}
\def\spadfun{\spadname{fun}}
\def\spadtype{\spadname{type}}

\begin{document}

\spadop`a`
\spadop`^`
\spadop`~=`
\spadop`/\`
\spadop`\/`
\spadop`#`

\spadfun`foo`
\spadfun`foo_bar`
\spadfun`setelt!`

\spadtype`Integer`
\spadtype|Foo(%)|
\spadtype!IntegerCategory&!

\printindex
\end{document}

Reply via email to