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