old-www/HOWTO/LinuxDoc+Emacs+Ispell-HOWTO...

97 lines
4.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>LinuxDoc+Emacs+Ispell-HOWTO: An insert-sgml-header function </TITLE>
<LINK HREF="LinuxDoc+Emacs+Ispell-HOWTO-6.html" REL=previous>
<LINK HREF="LinuxDoc+Emacs+Ispell-HOWTO.html#toc7" REL=contents>
</HEAD>
<BODY>
Next
<A HREF="LinuxDoc+Emacs+Ispell-HOWTO-6.html">Previous</A>
<A HREF="LinuxDoc+Emacs+Ispell-HOWTO.html#toc7">Contents</A>
<HR>
<H2><A NAME="insert-sgml-header"></A> <A NAME="s7">7. An <CODE>insert-sgml-header</CODE> function </A> </H2>
<P>This function will let the user insert a customised header for a
Linux Documentation Project document in a file. It can be called
automatically when one opens a new file, or explicitly, by the user.
<P>
<P>This function prompts the user, through the <EM>mini-buffer</EM>,
for some pieces of information, some of which are necessary, some of which are
not.
<P>First comes the title. If none is given, the function returns
immediately, and inserts nothing. Then comes the date, the author, his
e-mail and home page (these last two are optional).
<P>Then comes a request for the name of the translator. If there is
none, just type <EM>Return</EM>, and no further prompting about a
hypothetical translator will be done. If there is one, you are asked for
his e-mail and home page (optional as well).
<P>This function then prints your request to the current buffer,
including of course all the information you typed in a set up form, and
including as well the tags which will serve for the abstract and the
first chapter. It finally puts the cursor
in the place where the abstract needs to be typed.
<P>
<PRE>
(defun insert-sgml-header ()
"Inserts the header for a LinuxDoc document"
(interactive)
(let (title author email home translator email-translator home-translator date
starting-point)
(setq title (read-from-minibuffer "Title: "))
(if (> (length title) 0)
(progn
(setq date (read-from-minibuffer "Date: ")
author (read-from-minibuffer "Author: ")
email (read-from-minibuffer "Author e-mail: ")
home (read-from-minibuffer "Author home page: http://")
translator (read-from-minibuffer "Translator: "))
(insert "&lt;!doctype linuxdoc system>\n&lt;article>\n&lt;title>")
(insert title)
(insert "&lt;/title>\n&lt;author>\nAuthor: ") (insert author) (insert "&lt;newline>\n")
(if (> (length email) 0)
(progn
(insert "&lt;htmlurl url=\"mailto:")
(insert email) (insert "\" name=\"") (insert email)
(insert "\">&lt;newline>\n")))
(if (> (length home) 0)
(progn
(insert "&lt;htmlurl url=\"http://")
(insert home) (insert "\" name=\"") (insert home)
(insert "\">\n&lt;newline>")))
(if (> (length translator) 0)
(progn
(setq email-translator (read-from-minibuffer "Translator e-mail: ")
home-translator (read-from-minibuffer "Translator home page: http://"))
(insert "Translator : ")
(insert translator)
(insert "&lt;newline>\n")
(if (> (length email-translator) 0)
(progn
(insert "&lt;htmlurl url=\"mailto:")
(insert email-translator) (insert "\" name=\"")
(insert email-translator)
(insert "\">&lt;newline>\n")))
(if (> (length home-translator) 0)
(progn
(insert "&lt;htmlurl url=\"http://")
(insert home-translator) (insert "\" name=\"")
(insert home-translator)
(insert "\">&lt;newline>\n")))))
(insert "&lt;/author>\n&lt;date>\n")
(insert date)
(insert "\n&lt;/date>\n\n&lt;abstract>\n")
(setq point-beginning (point))
(insert "\n&lt;/abstract>\n&lt;toc>\n\n&lt;sect>\n&lt;p>\n\n\n&lt;/sect>\n\n&lt;/article>\n")
(goto-char point-beginning)
))))
</PRE>
<HR>
Next
<A HREF="LinuxDoc+Emacs+Ispell-HOWTO-6.html">Previous</A>
<A HREF="LinuxDoc+Emacs+Ispell-HOWTO.html#toc7">Contents</A>
</BODY>
</HTML>