Commit | Line | Data |
---|---|---|
0a10297a | 1 | ;;; forms-d2.el --- demo forms-mode -*- no-byte-compile: t -*- |
1270d7ca | 2 | |
73b0cd50 | 3 | ;; Copyright (C) 1991, 1994-1997, 2001-2011 Free Software Foundation, Inc. |
6110bf7c | 4 | |
1270d7ca DL |
5 | ;; Author: Johan Vromans <jvromans@squirrel.nl> |
6 | ;; Created: 1989 | |
7 | ||
e8af40ee PJ |
8 | ;; This file is part of GNU Emacs. |
9 | ||
eb3fa2cf | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
74ce2879 | 11 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
12 | ;; the Free Software Foundation, either version 3 of the License, or |
13 | ;; (at your option) any later version. | |
74ce2879 GM |
14 | |
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. | |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
74ce2879 | 22 | |
e8af40ee PJ |
23 | ;;; Commentary: |
24 | ||
1270d7ca DL |
25 | ;; This sample forms exploit most of the features of forms mode. |
26 | ||
e8af40ee PJ |
27 | ;;; Code: |
28 | ||
1270d7ca | 29 | ;; Set the name of the data file. |
da3cc79d | 30 | (setq forms-file (expand-file-name "forms-d2.dat" data-directory)) |
1270d7ca DL |
31 | |
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))) | |
46 | ||
47 | ;; The following functions are used by this form for layout purposes. | |
48 | ;; | |
49 | (defun arch-tocol (target &optional fill) | |
ed6565df | 50 | "Produces a string to skip to column TARGET. Prepends newline if needed. |
1270d7ca DL |
51 | The optional FILL should be a character, used to fill to the column." |
52 | (if (null fill) | |
ed6565df | 53 | (setq fill ?\s)) |
1270d7ca DL |
54 | (if (< target (current-column)) |
55 | (concat "\n" (make-string target fill)) | |
56 | (make-string (- target (current-column)) fill))) | |
57 | ;; | |
71296446 | 58 | (defun arch-rj (target field &optional fill) |
1270d7ca | 59 | "Produces a string to skip to column TARGET minus the width of field FIELD. |
ed6565df | 60 | Prepends newline if needed. The optional FILL should be a character, |
1270d7ca DL |
61 | used to fill to the column." |
62 | (arch-tocol (- target (length (nth field forms-fields))) fill)) | |
63 | ||
64 | ;; Record filters. | |
65 | ;; | |
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 | |
71 | ) | |
72 | (setq forms-new-record-filter 'arch-new-record-filter) | |
73 | ||
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 | |
99 | )) | |
100 | ||
101 | ;; That's all, folks! | |
e8af40ee PJ |
102 | |
103 | ;;; forms-d2.el ends here |