help-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-texinfo] wish: type on separate (preceding) line


From: Karl Berry
Subject: Re: [help-texinfo] wish: type on separate (preceding) line
Date: Sat, 21 May 2011 23:04:23 GMT

Hi,

Getting back to your wish from March (sorry):

    but it would be nice IMO to make it look like:

      void *                                                           
[Function]
      svz_server_configure (svz servertype t * server, char * name,

I've implemented a new option in texinfo.tex for this.  The official
command will be address@hidden on|off' (I'm open to better suggestions
for the name), but you can test it with address@hidden txideftypefnnl'.

I've committed a new texinfo.tex to Texinfo CVS.  Before I push it out,
can you easily try it from there?  Also attaching a patch for posterity,
no idea if it will apply to whatever texinfo.tex you have now.

Also attaching my test file.  (I think it looks very good, BTW, but I'm
feeling too conservative to change the default.)

Let me know, and thanks.

Patrice, can you implement this in tp, please?  (Except for Docbook and
XML, of course.)

karl


Attachment: deftypegnu.txi
Description: Binary data

--- texinfo.tex 11 May 2011 23:40:29 -0000      1.345
+++ texinfo.tex 21 May 2011 23:00:07 -0000
-%%% Untyped functions:
+\newif\ifdoingtypefn       % doing typed function?
+\newif\ifrettypeownline    % typeset return type on its own line?
+
+% @deftypefnnl on|off says whether the return type of typed functions
+% are printed on their own line.  This affects @deftypefn, @deftypeop,
+% and @deftypemethod.
+% 
+\parseargdef\deftypefnnl{%
+  \def\temp{#1}%
+  \ifx\temp\onword
+    \expandafter\let\csname SETtxideftypefnnl\endcsname
+      = \empty
+  \else\ifx\temp\offword
+    \expandafter\let\csname SETtxideftypefnnl\endcsname
+      = \relax
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @txideftypefnnl value `\temp',
+                must be on|off}%
+  \fi\fi
+}
+
+% Untyped functions:
 
@@ -6811,2 +6824,3 @@ end
   \dosubind{fn}{\code{#4}}{#1}%
+  \doingtypefntrue
   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
@@ -6871,2 +6886,3 @@ end
 \def\defname#1#2#3{%
+  \par
   % Get the values of \leftskip and \rightskip as they were outside the @def...
@@ -6874,3 +6890,13 @@ end
   %
-  % How we'll format the type name.  Putting it in brackets helps
+  % Determine if we are typesetting the return type of a typed function
+  % on a line by itself.
+  \rettypeownlinefalse
+  \ifdoingtypefn  % doing a typed function specifically?
+    % then check user option for putting return type on its own line:
+    \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
+      \rettypeownlinetrue
+    \fi
+  \fi
+  %
+  % How we'll format the category name.  Putting it in brackets helps
   % distinguish it from the body text that may end up on the next line
@@ -6880,3 +6906,6 @@ end
   %
-  % Figure out line sizes for the paragraph shape.
+  % Figure out line sizes for the paragraph shape.  We'll always have at
+  % least two.
+  \tempnum = 2
+  %
   % The first line needs space for \box0; but if \rightskip is nonzero,
@@ -6884,8 +6913,18 @@ end
   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
+  %
+  % If doing a return type on its own line, we'll have another line.
+  \ifrettypeownline
+    \advance\tempnum by 1
+    \def\maybeshapeline{0in \hsize}%
+  \else
+    \def\maybeshapeline{}%
+  \fi
+  %
   % The continuations:
   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
-  % (plain.tex says that \dimen1 should be used only as global.)
-  \parshape 2 0in \dimen0 \defargsindent \dimen2
   %
-  % Put the type name to the right margin.
+  % The final paragraph shape:
+  \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
+  %
+  % Put the category name at the right margin.
   \noindent
@@ -6911,4 +6950,12 @@ end
     \df \tt
-    \def\temp{#2}% return value type
-    \ifx\temp\empty\else \tclose{\temp} \fi
+    \def\temp{#2}% text of the return type
+    \ifx\temp\empty\else
+      \tclose{\temp}% typeset the return type
+      \ifrettypeownline
+        % put return type on its own line; prohibit line break following:
+        \hfil\vadjust{\nobreak}\break  
+      \else
+        \space  % type on same line, so just followed by a space
+      \fi
+    \fi           % no return type
     #3% output function name

reply via email to

[Prev in Thread] Current Thread [Next in Thread]