* doc/lispref/processes.texi (Query Before Exit): Remove obsolete function
[emacs.git] / lisp / forms-d2.el
blob7d7336030dbac762b293f840c36ba02130911b2b
1 ;;; forms-d2.el --- demo forms-mode -*- no-byte-compile: t -*-
3 ;; Copyright (C) 1991, 1994-1997, 2001-2012 Free Software Foundation, Inc.
5 ;; Author: Johan Vromans <jvromans@squirrel.nl>
6 ;; Created: 1989
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; This sample forms exploit most of the features of forms mode.
27 ;;; Code:
29 ;; Set the name of the data file.
30 (setq forms-file (expand-file-name "forms-d2.dat" data-directory))
32 ;; Use 'forms-enumerate' to set field names and number thereof.
33 (setq forms-number-of-fields
34 (forms-enumerate
35 '(arch-newsgroup ; 1
36 arch-volume ; 2
37 arch-issue ; and ...
38 arch-article ; ... so
39 arch-shortname ; ... ... on
40 arch-parts
41 arch-from
42 arch-longname
43 arch-keywords
44 arch-date
45 arch-remarks)))
47 ;; The following functions are used by this form for layout purposes.
49 (defun arch-tocol (target &optional fill)
50 "Produces a string to skip to column TARGET. Prepends newline if needed.
51 The optional FILL should be a character, used to fill to the column."
52 (if (null fill)
53 (setq fill ?\s))
54 (if (< target (current-column))
55 (concat "\n" (make-string target fill))
56 (make-string (- target (current-column)) fill)))
58 (defun arch-rj (target field &optional fill)
59 "Produces a string to skip to column TARGET minus the width of field FIELD.
60 Prepends newline if needed. The optional FILL should be a character,
61 used to fill to the column."
62 (arch-tocol (- target (length (nth field forms-fields))) fill))
64 ;; Record filters.
66 (defun arch-new-record-filter (the-record)
67 "Form a new record with some defaults."
68 (aset the-record arch-from (user-full-name))
69 (aset the-record arch-date (current-time-string))
70 the-record ; return it
72 (setq forms-new-record-filter 'arch-new-record-filter)
74 ;; The format list.
75 (setq forms-format-list
76 (list
77 "====== Public Domain Software Archive ======\n\n"
78 arch-shortname
79 " - " arch-longname
80 "\n\n"
81 "Article: " arch-newsgroup
82 "/" arch-article
83 " "
84 '(arch-tocol 40)
85 "Issue: " arch-issue
86 " "
87 '(arch-rj 73 10)
88 "Date: " arch-date
89 "\n\n"
90 "Submitted by: " arch-from
91 "\n"
92 '(arch-tocol 79 ?-)
93 "\n"
94 "Keywords: " arch-keywords
95 "\n\n"
96 "Parts: " arch-parts
97 "\n\n====== Remarks ======\n\n"
98 arch-remarks
101 ;; That's all, folks!
103 ;;; forms-d2.el ends here