Mercurial > emacs
annotate vms/make-mms-derivative.el @ 67004:5a972cf172a7
(ls-lisp-format-file-size): Format file size with 9 digits, not 8, to avoid
misalignment for files larger than 100MB.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 19 Nov 2005 11:38:23 +0000 |
parents | 23a17af379b1 |
children | dc2d5a6655a3 f9a65d7ebd29 |
rev | line source |
---|---|
53152 | 1 ;;; make-mms-derivative.el --- framework to do horrible things for VMS support |
2 | |
60814
a9ece659b645
Update year in copyright, commentary; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60813
diff
changeset
|
3 ;; Copyright (C) 2005 Free Software Foundation, Inc. |
53152 | 4 |
5 ;; Author: Thien-Thi Nguyen <ttn@gnu.org> | |
6 ;; Keywords: maint build vms mms makefile levitte autoconf war-is-a-lose | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
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 2, or (at your option) | |
13 ;; any later version. | |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64083 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
53152 | 24 |
25 ;;; Commentary: | |
26 | |
60854 | 27 ;; Under VMS the standard make-like program is called MMS, which looks |
28 ;; for an input file in the default directory named DESCRIP.MMS and runs | |
29 ;; the DCL command rules therein. As of 2005, the build process | |
30 ;; requires a hand translation of the Makefile.in and Emacs-specific | |
31 ;; methodology to DCL and TPU commands, so to alleviate this pain, we | |
32 ;; provide `make-mms-derivative', which given a source FILENAME, inserts | |
33 ;; the file contents in a new buffer and loads FILENAME-2mms. The lisp | |
34 ;; code in the -2mms file can (do whatever -- it's emacs -- and), as | |
35 ;; long as it arranges to write out the modified buffer after loading by | |
36 ;; specifying, on a line of its own, the directive: | |
37 ;; | |
38 ;; :output RELATIVE-OUTPUT | |
39 ;; | |
40 ;; where RELATIVE-OUTPUT is a filename (a string) relative to FILENAME's | |
41 ;; directory, typically something simple like "descrip.mms_in_in". Only | |
42 ;; the first :output directive is recognized. | |
53152 | 43 ;; |
60854 | 44 ;; The only other special directive at this time has the form: |
45 ;; | |
46 ;; :gigo NAME | |
47 ;; ;;blah blah blah | |
48 ;; ;;(more text here) | |
53152 | 49 ;; |
60854 | 50 ;; NAME is anything distinguishable w/ `eq' (number, symbol or keyword). |
51 ;; This associates NAME with the block of text starting immediately below | |
52 ;; the :gigo directive and ending at the first line that does not begin | |
53 ;; with two semicolons (which are stripped from each line in the block). | |
54 ;; To insert this block of text, pass NAME to `make-mms-derivative-gigo'. | |
55 ;; | |
56 ;; Directives are scanned before normal evaluation, so their placement | |
57 ;; in the file is not important. During loading, plain strings are | |
58 ;; displayed in the echo area, prefixed with the current line number. | |
59 ;; | |
60 ;; Over the long run, the convenience functions provided (see source) | |
53153
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
61 ;; will be augmented by factoring maximally the -2mms files, squeezing |
53152 | 62 ;; as much algorithm out of those nasty heuristics as possible. What |
63 ;; makes them nasty is not that they rely on the conventions of the | |
64 ;; Emacs makefiles; that's no big deal. What makes them nasty is that | |
65 ;; they rely on the conventions of separately maintained tools (namely | |
60854 | 66 ;; Autoconf for VMS and GNU Autoconf), and the separation of conventions |
67 ;; is how people drift apart, dragging their software behind | |
68 ;; mercilessly. | |
53152 | 69 ;; |
70 ;; In general, codified thought w/o self-synchronization is doomed. | |
71 ;; That a generation would eat its young (most discriminatingly, even) | |
72 ;; is no reason GNU cannot build around such woe. | |
73 | |
74 ;;; Code: | |
75 | |
76 (defvar make-mms-derivative-data nil | |
60854 | 77 "Plist of data specific to `make-mms-derivative'.") |
53152 | 78 |
79 (defun make-mms-derivative-data (key &optional newval) | |
60854 | 80 (if newval (setq make-mms-derivative-data |
81 (plist-put make-mms-derivative-data key newval)) | |
82 (plist-get make-mms-derivative-data key))) | |
53152 | 83 |
60854 | 84 (defun make-mms-derivative-gigo (name) |
85 "Insert the text associated with :gigo NAME." | |
86 (insert (cdr (assq name (make-mms-derivative-data :gigo))))) | |
53152 | 87 |
60854 | 88 (defun make-mms-derivative (filename) |
89 "Take FILENAME contents, load FILENAME-2mms, and write out the result. | |
90 The output file is specified by the :output directive in FILENAME-2mms. | |
91 See commentary of make-mms-derivative.el for full documentation." | |
53152 | 92 (interactive "fSource File: ") |
60854 | 93 (let* ((todo (let ((fn (concat filename "-2mms"))) |
94 (unless (file-exists-p fn) | |
95 (error "Could not find %s" fn)) | |
96 (set-buffer (get-buffer-create " *make-mms-derivative todo*")) | |
97 (insert-file-contents fn) | |
98 (current-buffer))) | |
99 (deriv (get-buffer-create (format "*mms-derivative: %s" | |
100 (file-relative-name filename)))) | |
101 output gigo form) | |
102 (set-buffer todo) | |
103 (re-search-forward "^:output") | |
104 (setq output (expand-file-name (read (current-buffer)) | |
105 (file-name-directory filename))) | |
106 (goto-char (point-min)) | |
107 (while (re-search-forward "^:gigo" (point-max) t) | |
108 (let ((name (read (current-buffer))) | |
109 (p (progn (forward-line 1) (point)))) | |
110 (while (looking-at ";;") | |
111 (delete-char 2) | |
112 (forward-line 1)) | |
113 (setq gigo (cons (cons name (buffer-substring p (point))) gigo)) | |
114 (delete-region p (point)))) | |
115 (message "Munging...") | |
116 (switch-to-buffer deriv) | |
117 (erase-buffer) | |
118 (insert-file-contents filename) | |
119 (set (make-local-variable 'make-mms-derivative-data) | |
120 (list :gigo gigo)) | |
121 (set-buffer todo) | |
122 (goto-char (point-min)) | |
123 (while (condition-case nil | |
124 (setq form (read (current-buffer))) | |
125 (end-of-file nil)) | |
126 (if (stringp form) | |
127 (message "%d: %s" (count-lines (point-min) (point)) form) | |
128 (save-excursion | |
129 (set-buffer deriv) | |
130 (eval form)))) | |
131 (set-buffer deriv) | |
132 (message "Munging...done") | |
133 (write-file output) | |
134 (kill-buffer todo) | |
135 (kill-buffer deriv))) | |
53152 | 136 |
137 (provide 'make-mms-derivative) | |
138 | |
53155 | 139 ;;; arch-tag: a5b08625-3952-4053-be16-296220e27bb0 |
53152 | 140 ;;; make-mms-derivative.el ends here |