Mercurial > emacs
annotate vms/make-mms-derivative.el @ 60831:74476de5b3b7
*** empty log message ***
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 22 Mar 2005 21:51:50 +0000 |
parents | a9ece659b645 |
children | 6c3c9561257e |
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 | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; Under OpenVMS the standard make-like program is called MMS, which | |
28 ;; looks for an input file in the default directory named DESCRIP.MMS | |
60814
a9ece659b645
Update year in copyright, commentary; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
60813
diff
changeset
|
29 ;; and runs the DCL command rules therein. As of 2005, the build |
53152 | 30 ;; process requires a hand translation of the Makefile.in and related |
31 ;; Emacs-specific methodology to DCL and TPU commands, so to alleviate | |
32 ;; this pain, we provide `make-mms-derivative', which given a source | |
33 ;; FILENAME (under `make-mms-derivative-root-dir'), inserts the file | |
53153
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
34 ;; contents in a new buffer and loads FILENAME-2mms. The elisp in the |
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
35 ;; -2mms file can (do whatever -- it's emacs -- and) arrange to write |
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
36 ;; out the modified buffer after FILENAME-2mms loading by using: |
53152 | 37 ;; |
38 ;; (make-mms-derivative-data 'write-under-root RELATIVE-FILENAME) | |
39 ;; | |
40 ;; where RELATIVE-FILENAME is something like "src/descrip.mms_in_in". | |
41 ;; Over the long run, the convenience procedures provided (see source) | |
53153
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
42 ;; will be augmented by factoring maximally the -2mms files, squeezing |
53152 | 43 ;; as much algorithm out of those nasty heuristics as possible. What |
44 ;; makes them nasty is not that they rely on the conventions of the | |
45 ;; Emacs makefiles; that's no big deal. What makes them nasty is that | |
46 ;; they rely on the conventions of separately maintained tools (namely | |
47 ;; Autoconf 1.11 under OpenVMS and the rest of GNU), and the separation | |
48 ;; of conventions is how people drift apart, dragging their software | |
49 ;; behind mercilessly. | |
50 ;; | |
51 ;; In general, codified thought w/o self-synchronization is doomed. | |
52 ;; That a generation would eat its young (most discriminatingly, even) | |
53 ;; is no reason GNU cannot build around such woe. | |
54 | |
55 ;;; Code: | |
56 | |
53186
d6dc58f9beaa
(make-mms-derivative-root-dir): Update.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53156
diff
changeset
|
57 (defvar make-mms-derivative-root-dir "AXPA:[TTN.EMACS.EMACS212_3]" |
53152 | 58 "Source tree root directory.") |
59 | |
60 (defvar make-mms-derivative-data nil | |
61 "Alist of data specific to `make-mms-derivative'.") | |
62 | |
63 (defun make-mms-derivative-data (key &optional newval) | |
64 (if newval | |
65 (setq make-mms-derivative-data | |
66 (cons (cons key newval) make-mms-derivative-data)) | |
67 (cdr (assq key make-mms-derivative-data)))) | |
68 | |
69 (defmacro make-mms-derivative-progn (msg &rest body) | |
70 `(progn | |
71 (message "(%s) %s" (point) ,msg) | |
72 ,@body)) | |
73 | |
74 (put 'make-mms-derivative-progn 'lisp-indent-function 1) | |
75 | |
76 (defun make-mms-derivative-load-edits-file (name) | |
77 (make-mms-derivative-data 'edits-filename name) | |
53156
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
78 (let (raw-data |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
79 (cur (current-buffer)) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
80 (wbuf (get-buffer-create "*make-mms-derivative-load-edits-file work"))) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
81 (set-buffer wbuf) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
82 (insert-file-contents name) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
83 (keep-lines "^;;;[0-9]+;;") |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
84 (goto-char (point-max)) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
85 (while (re-search-backward "^;;;\\([0-9]+\\);;\\(.*\\)$" (point-min) t) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
86 (let* ((i (string-to-number (match-string 1))) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
87 (line (match-string 2)) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
88 (look (assq i raw-data))) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
89 (if look |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
90 (setcdr look (cons line (cdr look))) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
91 (setq raw-data (cons (list i line) raw-data))))) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
92 (kill-buffer wbuf) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
93 (set-buffer cur) |
60813
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
94 (mapcar (lambda (ent) |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
95 (setcdr ent (mapconcat (lambda (line) |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
96 (concat line "\n")) |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
97 (cdr ent) |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
98 ""))) |
53156
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
99 raw-data) |
4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53155
diff
changeset
|
100 (make-mms-derivative-data 'raw-data raw-data)) |
53152 | 101 (load name)) |
102 | |
103 (defun make-mms-derivative-insert-raw-data (n) | |
104 (insert (cdr (assq n (make-mms-derivative-data 'raw-data))))) | |
105 | |
106 (defun make-mms-derivative (file) | |
107 (interactive "fSource File: ") | |
108 (let ((root (expand-file-name make-mms-derivative-root-dir)) | |
109 (file (expand-file-name file))) | |
53186
d6dc58f9beaa
(make-mms-derivative-root-dir): Update.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53156
diff
changeset
|
110 (when (file-name-absolute-p (file-relative-name file root)) |
53152 | 111 (error "Not under root (%s)" root)) |
53153
95cc51c7ff64
(make-mms-derivative): Use suffix "-2mms"
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53152
diff
changeset
|
112 (let ((edits-filename (concat file "-2mms"))) |
53152 | 113 (unless (file-exists-p edits-filename) |
114 (error "Could not find %s" edits-filename)) | |
53186
d6dc58f9beaa
(make-mms-derivative-root-dir): Update.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53156
diff
changeset
|
115 (let ((buf (get-buffer-create |
d6dc58f9beaa
(make-mms-derivative-root-dir): Update.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53156
diff
changeset
|
116 (format "*mms-derivative: %s" |
d6dc58f9beaa
(make-mms-derivative-root-dir): Update.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53156
diff
changeset
|
117 (file-relative-name file root))))) |
53152 | 118 (message "Munging ...") |
119 (switch-to-buffer buf) | |
120 (erase-buffer) | |
121 (make-variable-buffer-local 'make-mms-derivative-data) | |
122 (insert-file file) | |
123 (make-mms-derivative-load-edits-file edits-filename) | |
124 (let ((out (make-mms-derivative-data 'write-under-root))) | |
60813
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
125 (when out |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
126 (write-file |
e5d5ea6a58f1
(make-mms-derivative-write-under-root): Delete func.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
53186
diff
changeset
|
127 (expand-file-name rel-filename make-mms-derivative-root-dir))) |
53152 | 128 (kill-buffer buf) |
129 (unless out (message "Munging ... done"))))))) | |
130 | |
131 (provide 'make-mms-derivative) | |
132 | |
53155 | 133 ;;; arch-tag: a5b08625-3952-4053-be16-296220e27bb0 |
53152 | 134 ;;; make-mms-derivative.el ends here |