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) ))))