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