annotate lisp/progmodes/mantemp.el @ 96115:6d96d49c7ae7

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Fri, 20 Jun 2008 15:48:08 +0000
parents 52b7a8c22af5
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 16879
diff changeset
1 ;;; mantemp.el --- create manual template instantiations from g++ 2.7.2 output
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
79717
a1342e6e097a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78234
diff changeset
3 ;; Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
64699
629afbe74e61 Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents: 64085
diff changeset
4 ;; Free Software Foundation, Inc.
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Tom Houlder <thoulder@icor.fr>
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Created: 10 Dec 1996
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: g++, templates
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; (at your option) any later version.
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
20 ;; GNU General Public License for more details.
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; The following is a typical error message from g++ using STL (here
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; with split lines):
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; AFile.o(.text+0x2d5): undefined reference to
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; `vector<double>::begin(void)'
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; AFile.o(.text+0x2e7): undefined reference to
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; `vector<double>::insert(double *, unsigned int, double const &)'
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; AnotherFile.o(.text+0x226b8): undefined reference to
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; `operator!=(rb_tree<basic_string<char>, pair<basic_string<char>
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; const, AClass *>, select1st<pair<basic_string<char> const, AClass
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; *>, basic_string<char> >, less<basic_string<char> > >::iterator
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; const &, rb_tree<basic_string<char>, pair<basic_string<char>
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; const, AClass *>, select1st<pair<basic_string<char> const, AClass
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; *>, basic_string<char> >, less<basic_string<char> > >::iterator
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; const &)'
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; The message means that in the object file AFile.o there is one
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; uninstantiated template class, vector<double>, and in AnotherFile.o
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; there is one uninstantiated template function, operator!=(...). To
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; turn this output into manual template instantiations, copy from the
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; first name of an objective file (here this is AFile.o) to right
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; after the very last `'' of the output. Put this in a buffer and
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
49 ;; call `mantemp-make-mantemps-buffer' with the point in the buffer.
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
50 ;; You can also use `mantemp-make-mantemps-region' directly on the
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; region if the output is already in Emacs.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; The resulting buffer yields (connect the three output lines above
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; if you want to try):
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; template operator!=(rb_tree<basic_string<char>,
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; pair<basic_string<char> const, AClass *>,
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;; select1st<pair<basic_string<char> const, AClass *>,
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; basic_string<char> >, less<basic_string<char> > >::iterator const
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; &, rb_tree<basic_string<char>, pair<basic_string<char> const,
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; AClass *>, select1st<pair<basic_string<char> const, AClass *>,
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; basic_string<char> >, less<basic_string<char> > >::iterator const
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; &);
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; template class vector<double>;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;;
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; which can be included in your C++ program. However, its probably
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; better to include the necessary header files in the buffer and
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; compile it as a stand alone implementation file.
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
69 ;;
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
70 ;; Sometimes, an uninstantiated template may cause a message like the
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
71 ;; following
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
72 ;;
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
73 ;; main.cc:66: invalid use of undefined type
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
74 ;; `struct valarray<double,arrayminusopclass<double,c_array<double> > >'
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
75 ;;
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
76 ;; Follow the same procedure as above and the line is changed to
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
77 ;;
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
78 ;; template struct valarray<double,
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
79 ;; arrayminusopclass<double,c_array<double> > >;
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; g++ does not output the templates that are needed by the
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; uninstantiated templates. Therefore you will often get new error
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; messages after the first instantiations have been included and you
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;; must repeat the operation.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 ;;; Code:
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (defun mantemp-remove-comments ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 "Remove g++ comments surrounding each function and member function."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (save-excursion
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (message "Removing comments")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (while (re-search-forward "^[A-z\.()+0-9: ]*`\\|'.*$" nil t)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (replace-match ""))))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (defun mantemp-remove-memfuncs ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 "Remove member function extensions so that only class names remain."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (save-excursion
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;; Remove conversion operator extensions.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (message "Removing member function extensions")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (while (re-search-forward
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 "^[A-z :&*<>~=,0-9+]*>::operator " nil t nil)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (backward-char 11)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
106 (delete-region (point) (line-end-position))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; Remove other member function extensions.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (message "Removing member function extensions")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (backward-char 2)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
113 (delete-region (point) (line-end-position))))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (defun mantemp-sort-and-unique-lines ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 "Eliminate all consecutive duplicate lines in the buffer."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (save-excursion
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (message "Sorting")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (sort-regexp-fields nil "^.*$" "\\&"
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (point-min)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (point-max))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (message "Removing consecutive duplicate lines")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (while (re-search-forward "\\(^.+\\)\n\\1" nil t nil)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (forward-line -1)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (beginning-of-line)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
128 (delete-region (point) (progn (forward-line 1) (point)))))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defun mantemp-insert-cxx-syntax ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 "Insert C++ syntax around each template class and function.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 Insert 'template class' for classes, 'template' for
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 functions and add the statement delimiter `;' at the end of
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 the lines."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (save-excursion
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;; Insert ';' at the end of each nonempty line.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (message "Inserting `;' at the ends")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (while (re-search-forward ".+$" nil t)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (insert ";")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (if (not (equal (point) (point-max)))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (forward-char))))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;; We first insert 'template class' at each nonempty line and
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; subsequently remove 'class' for functions so we don't need to
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; both scan for classes and functions.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (message "Inserting 'template class' for classes")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (while (re-search-forward "^.+" nil t)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (beginning-of-line)
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
152 (if (looking-at "struct[\\t ]+\\|class[\\t ]+")
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
153 (insert "template ")
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
154 (insert "template class "))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (goto-char (point-min))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (message "Inserting 'template' for functions")
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (while (re-search-forward
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (progn
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (beginning-of-line)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (forward-word 1)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
162 (delete-region (point) (progn (forward-word 1) (point)))))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (defun mantemp-make-mantemps ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 "Gathering interface to the functions modifying the buffer."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (mantemp-remove-comments)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (mantemp-remove-memfuncs)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (mantemp-sort-and-unique-lines)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (mantemp-insert-cxx-syntax))
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (defun mantemp-make-mantemps-buffer ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 "Make manual template instantiations from g++ error messages in the buffer.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 Scan the output of g++ describing uninstantiated template
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 classes and functions and generate the corresponding C++
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 manual template instantiations. The output is supposed to
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 have been placed in the current buffer and the current buffer
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 should otherwise be empty.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 See the commentary in file mantemp.el for an example of use."
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (interactive)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (mantemp-make-mantemps)
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
182 (message "Done"))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (defun mantemp-make-mantemps-region ()
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 "Make manual template instantiations from g++ error messages in the region.
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
186 This function does the same thing as `mantemp-make-mantemps-buffer',
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
187 but operates on the region."
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (interactive)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (let ((cur-buf (current-buffer))
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
190 (mantemp-buffer (generate-new-buffer "*mantemp*"))
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
191 (str (buffer-substring (mark) (point))))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; Copy the region to a temporary buffer, make the C++ code there
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; and copy the result back to the current buffer.
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (set-buffer mantemp-buffer)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
195 (insert str)
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (mantemp-make-mantemps)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
197 (setq str (buffer-string))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (set-buffer cur-buf)
77374
74462e953a2c (mantemp-make-mantemps-region)
Chong Yidong <cyd@stupidchicken.com>
parents: 75347
diff changeset
199 (insert str)
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (kill-buffer mantemp-buffer))
16879
b020aae1fa01 (mantemp-insert-cxx-syntax): Recognize non-class templates.
Richard M. Stallman <rms@gnu.org>
parents: 16878
diff changeset
201 (message "Done"))
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (provide 'mantemp)
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79717
diff changeset
205 ;; arch-tag: 49794712-3b1b-4baa-9785-39556cb52c94
16878
ffc3290d43bf Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 ;;; mantemp.el ends here