Insert-sgml-header
程序之范例 读者在撰写一份 Linux Documentation Project 文件时,可以使用下列程序来启动自动插入自订的页首。
透过一 mini-buffer,上述程序会要求读者提供一些或许必要的信息。
它会先询问要输出的标题是什么,若您没有提供,则页首就不会显现标题。再来是日期,作者,作者的电子邮件帐号与 home page (最后两项可随意填入)。
接著它会询问翻译者的名字。若无,请直接键入 Return。若有,程序就会接著询问译者的电子邮件帐号及 home page (同样也是随意填入)。
再来它会把您的输入存入 current buffer,包括任何您输入的信息格式,及摘要和第一章的标签。之后它会将游标导向您要键入摘要的的地方。
(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 "<!doctype linuxdoc system>\n<article>\n<title>") (insert title) (insert "</title>\n<author>\nAuthor: ") (insert author) (insert "<newline>\n") (if (> (length email) 0) (progn (insert "<htmlurl url=\"mailto:") (insert email) (insert "\" name=\"") (insert email) (insert "\"><newline>\n"))) (if (> (length home) 0) (progn (insert "<htmlurl url=\"http://") (insert home) (insert "\" name=\"") (insert home) (insert "\">\n<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 "<newline>\n") (if (> (length email-translator) 0) (progn (insert "<htmlurl url=\"mailto:") (insert email-translator) (insert "\" name=\"") (insert email-translator) (insert "\"><newline>\n"))) (if (> (length home-translator) 0) (progn (insert "<htmlurl url=\"http://") (insert home-translator) (insert "\" name=\"") (insert home-translator) (insert "\"><newline>\n"))))) (insert "</author>\n<date>\n") (insert date) (insert "\n</date>\n\n<abstract>\n") (setq point-beginning (point)) (insert "\n</abstract>\n<toc>\n\n<sect>\n<p>\n\n\n</sect>\n\n</article>\n") (goto-char point-beginning) ))))