Mercurial > emacs
comparison vms/make-mms-derivative.el @ 90128:13796b0653c7
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-29
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 192-205)
- Update from CVS
- Use gdb-ui breakpoint faces on ttys too
- Tweak gdb-ui breakpoint faces
- Tweak info/.arch-inventory to identify info/.cvsignore as source
- Clean up gdb-ui breakpoint faces
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 24 Mar 2005 18:41:26 +0000 |
parents | 68c22ea6027c 6c3c9561257e |
children | f9a65d7ebd29 |
comparison
equal
deleted
inserted
replaced
90127:30ad2795fdab | 90128:13796b0653c7 |
---|---|
1 ;;; make-mms-derivative.el --- framework to do horrible things for VMS support | 1 ;;; make-mms-derivative.el --- framework to do horrible things for VMS support |
2 | 2 |
3 ;; Copyright (C) 2003 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2005 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Thien-Thi Nguyen <ttn@gnu.org> | 5 ;; Author: Thien-Thi Nguyen <ttn@gnu.org> |
6 ;; Keywords: maint build vms mms makefile levitte autoconf war-is-a-lose | 6 ;; Keywords: maint build vms mms makefile levitte autoconf war-is-a-lose |
7 ;; Favorite-TV-Game-Show: L'Eredità | |
8 | 7 |
9 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
10 | 9 |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 ;; 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 | 11 ;; it under the terms of the GNU General Public License as published by |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
24 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02111-1307, USA. |
25 | 24 |
26 ;;; Commentary: | 25 ;;; Commentary: |
27 | 26 |
28 ;; Under OpenVMS the standard make-like program is called MMS, which | 27 ;; Under VMS the standard make-like program is called MMS, which looks |
29 ;; looks for an input file in the default directory named DESCRIP.MMS | 28 ;; for an input file in the default directory named DESCRIP.MMS and runs |
30 ;; and runs the DCL command rules therein. As of 2003, the build | 29 ;; the DCL command rules therein. As of 2005, the build process |
31 ;; process requires a hand translation of the Makefile.in and related | 30 ;; requires a hand translation of the Makefile.in and Emacs-specific |
32 ;; Emacs-specific methodology to DCL and TPU commands, so to alleviate | 31 ;; methodology to DCL and TPU commands, so to alleviate this pain, we |
33 ;; this pain, we provide `make-mms-derivative', which given a source | 32 ;; provide `make-mms-derivative', which given a source FILENAME, inserts |
34 ;; FILENAME (under `make-mms-derivative-root-dir'), inserts the file | 33 ;; the file contents in a new buffer and loads FILENAME-2mms. The lisp |
35 ;; contents in a new buffer and loads FILENAME-2mms. The elisp in the | 34 ;; code in the -2mms file can (do whatever -- it's emacs -- and), as |
36 ;; -2mms file can (do whatever -- it's emacs -- and) arrange to write | 35 ;; long as it arranges to write out the modified buffer after loading by |
37 ;; out the modified buffer after FILENAME-2mms loading by using: | 36 ;; specifying, on a line of its own, the directive: |
38 ;; | 37 ;; |
39 ;; (make-mms-derivative-data 'write-under-root RELATIVE-FILENAME) | 38 ;; :output RELATIVE-OUTPUT |
40 ;; | 39 ;; |
41 ;; where RELATIVE-FILENAME is something like "src/descrip.mms_in_in". | 40 ;; where RELATIVE-OUTPUT is a filename (a string) relative to FILENAME's |
42 ;; Over the long run, the convenience procedures provided (see source) | 41 ;; directory, typically something simple like "descrip.mms_in_in". Only |
42 ;; the first :output directive is recognized. | |
43 ;; | |
44 ;; The only other special directive at this time has the form: | |
45 ;; | |
46 ;; :gigo NAME | |
47 ;; ;;blah blah blah | |
48 ;; ;;(more text here) | |
49 ;; | |
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) | |
43 ;; will be augmented by factoring maximally the -2mms files, squeezing | 61 ;; will be augmented by factoring maximally the -2mms files, squeezing |
44 ;; as much algorithm out of those nasty heuristics as possible. What | 62 ;; as much algorithm out of those nasty heuristics as possible. What |
45 ;; makes them nasty is not that they rely on the conventions of the | 63 ;; makes them nasty is not that they rely on the conventions of the |
46 ;; Emacs makefiles; that's no big deal. What makes them nasty is that | 64 ;; Emacs makefiles; that's no big deal. What makes them nasty is that |
47 ;; they rely on the conventions of separately maintained tools (namely | 65 ;; they rely on the conventions of separately maintained tools (namely |
48 ;; Autoconf 1.11 under OpenVMS and the rest of GNU), and the separation | 66 ;; Autoconf for VMS and GNU Autoconf), and the separation of conventions |
49 ;; of conventions is how people drift apart, dragging their software | 67 ;; is how people drift apart, dragging their software behind |
50 ;; behind mercilessly. | 68 ;; mercilessly. |
51 ;; | 69 ;; |
52 ;; In general, codified thought w/o self-synchronization is doomed. | 70 ;; In general, codified thought w/o self-synchronization is doomed. |
53 ;; That a generation would eat its young (most discriminatingly, even) | 71 ;; That a generation would eat its young (most discriminatingly, even) |
54 ;; is no reason GNU cannot build around such woe. | 72 ;; is no reason GNU cannot build around such woe. |
55 | 73 |
56 ;;; Code: | 74 ;;; Code: |
57 | 75 |
58 (defvar make-mms-derivative-root-dir "AXPA:[TTN.EMACS.EMACS212_3]" | |
59 "Source tree root directory.") | |
60 | |
61 (defvar make-mms-derivative-data nil | 76 (defvar make-mms-derivative-data nil |
62 "Alist of data specific to `make-mms-derivative'.") | 77 "Plist of data specific to `make-mms-derivative'.") |
63 | 78 |
64 (defun make-mms-derivative-data (key &optional newval) | 79 (defun make-mms-derivative-data (key &optional newval) |
65 (if newval | 80 (if newval (setq make-mms-derivative-data |
66 (setq make-mms-derivative-data | 81 (plist-put make-mms-derivative-data key newval)) |
67 (cons (cons key newval) make-mms-derivative-data)) | 82 (plist-get make-mms-derivative-data key))) |
68 (cdr (assq key make-mms-derivative-data)))) | |
69 | 83 |
70 (defun make-mms-derivative-write-under-root (rel-filename) | 84 (defun make-mms-derivative-gigo (name) |
71 (write-file (expand-file-name rel-filename make-mms-derivative-root-dir))) | 85 "Insert the text associated with :gigo NAME." |
86 (insert (cdr (assq name (make-mms-derivative-data :gigo))))) | |
72 | 87 |
73 (defmacro make-mms-derivative-progn (msg &rest body) | 88 (defun make-mms-derivative (filename) |
74 `(progn | 89 "Take FILENAME contents, load FILENAME-2mms, and write out the result. |
75 (message "(%s) %s" (point) ,msg) | 90 The output file is specified by the :output directive in FILENAME-2mms. |
76 ,@body)) | 91 See commentary of make-mms-derivative.el for full documentation." |
77 | |
78 (put 'make-mms-derivative-progn 'lisp-indent-function 1) | |
79 | |
80 (defun make-mms-derivative-load-edits-file (name) | |
81 (make-mms-derivative-data 'edits-filename name) | |
82 (let (raw-data | |
83 (cur (current-buffer)) | |
84 (wbuf (get-buffer-create "*make-mms-derivative-load-edits-file work"))) | |
85 (set-buffer wbuf) | |
86 (insert-file-contents name) | |
87 (keep-lines "^;;;[0-9]+;;") | |
88 (goto-char (point-max)) | |
89 (while (re-search-backward "^;;;\\([0-9]+\\);;\\(.*\\)$" (point-min) t) | |
90 (let* ((i (string-to-number (match-string 1))) | |
91 (line (match-string 2)) | |
92 (look (assq i raw-data))) | |
93 (if look | |
94 (setcdr look (cons line (cdr look))) | |
95 (setq raw-data (cons (list i line) raw-data))))) | |
96 (kill-buffer wbuf) | |
97 (set-buffer cur) | |
98 (mapcar '(lambda (ent) | |
99 (setcdr ent (mapconcat '(lambda (line) | |
100 (concat line "\n")) | |
101 (cdr ent) | |
102 ""))) | |
103 raw-data) | |
104 (make-mms-derivative-data 'raw-data raw-data)) | |
105 (load name)) | |
106 | |
107 (defun make-mms-derivative-insert-raw-data (n) | |
108 (insert (cdr (assq n (make-mms-derivative-data 'raw-data))))) | |
109 | |
110 (defun make-mms-derivative (file) | |
111 (interactive "fSource File: ") | 92 (interactive "fSource File: ") |
112 (let ((root (expand-file-name make-mms-derivative-root-dir)) | 93 (let* ((todo (let ((fn (concat filename "-2mms"))) |
113 (file (expand-file-name file))) | 94 (unless (file-exists-p fn) |
114 (when (file-name-absolute-p (file-relative-name file root)) | 95 (error "Could not find %s" fn)) |
115 (error "Not under root (%s)" root)) | 96 (set-buffer (get-buffer-create " *make-mms-derivative todo*")) |
116 (let ((edits-filename (concat file "-2mms"))) | 97 (insert-file-contents fn) |
117 (unless (file-exists-p edits-filename) | 98 (current-buffer))) |
118 (error "Could not find %s" edits-filename)) | 99 (deriv (get-buffer-create (format "*mms-derivative: %s" |
119 (let ((buf (get-buffer-create | 100 (file-relative-name filename)))) |
120 (format "*mms-derivative: %s" | 101 output gigo form) |
121 (file-relative-name file root))))) | 102 (set-buffer todo) |
122 (message "Munging ...") | 103 (re-search-forward "^:output") |
123 (switch-to-buffer buf) | 104 (setq output (expand-file-name (read (current-buffer)) |
124 (erase-buffer) | 105 (file-name-directory filename))) |
125 (make-variable-buffer-local 'make-mms-derivative-data) | 106 (goto-char (point-min)) |
126 (insert-file file) | 107 (while (re-search-forward "^:gigo" (point-max) t) |
127 (make-mms-derivative-load-edits-file edits-filename) | 108 (let ((name (read (current-buffer))) |
128 (let ((out (make-mms-derivative-data 'write-under-root))) | 109 (p (progn (forward-line 1) (point)))) |
129 (when out (make-mms-derivative-write-under-root out)) | 110 (while (looking-at ";;") |
130 (kill-buffer buf) | 111 (delete-char 2) |
131 (unless out (message "Munging ... done"))))))) | 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))) | |
132 | 136 |
133 (provide 'make-mms-derivative) | 137 (provide 'make-mms-derivative) |
134 | 138 |
135 ;;; arch-tag: a5b08625-3952-4053-be16-296220e27bb0 | 139 ;;; arch-tag: a5b08625-3952-4053-be16-296220e27bb0 |
136 ;;; make-mms-derivative.el ends here | 140 ;;; make-mms-derivative.el ends here |