-;;; mantemp.el --- Create manual template instantiations from g++ 2.7.2 output.
+;;; mantemp.el --- create manual template instantiations from g++ 2.7.2 output
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Free Software Foundation, Inc.
;; Author: Tom Houlder <thoulder@icor.fr>
;; Created: 10 Dec 1996
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published
-;; by the Free Software Foundation; either version 2, or (at your
-;; option) any later version.
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
-;; GNU Emacs is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-;; General Public License for more details.
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; turn this output into manual template instantiations, copy from the
;; first name of an objective file (here this is AFile.o) to right
;; after the very last `'' of the output. Put this in a buffer and
-;; call mantemp-make-mantemps-buffer with the point in the buffer.
-;; You can also use mantemp-make-mantemps-region directly on the
+;; call `mantemp-make-mantemps-buffer' with the point in the buffer.
+;; You can also use `mantemp-make-mantemps-region' directly on the
;; region if the output is already in Emacs.
;;
;; The resulting buffer yields (connect the three output lines above
;; which can be included in your C++ program. However, its probably
;; better to include the necessary header files in the buffer and
;; compile it as a stand alone implementation file.
+;;
+;; Sometimes, an uninstantiated template may cause a message like the
+;; following
+;;
+;; main.cc:66: invalid use of undefined type
+;; `struct valarray<double,arrayminusopclass<double,c_array<double> > >'
+;;
+;; Follow the same procedure as above and the line is changed to
+;;
+;; template struct valarray<double,
+;; arrayminusopclass<double,c_array<double> > >;
;; g++ does not output the templates that are needed by the
;; uninstantiated templates. Therefore you will often get new error
"^[A-z :&*<>~=,0-9+]*>::operator " nil t nil)
(progn
(backward-char 11)
- (kill-line)))
+ (delete-region (point) (line-end-position))))
;; Remove other member function extensions.
(goto-char (point-min))
(message "Removing member function extensions")
(while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil)
(progn
(backward-char 2)
- (kill-line)))))
+ (delete-region (point) (line-end-position))))))
(defun mantemp-sort-and-unique-lines ()
"Eliminate all consecutive duplicate lines in the buffer."
(progn
(forward-line -1)
(beginning-of-line)
- (kill-line 1)))))
+ (delete-region (point) (progn (forward-line 1) (point)))))))
(defun mantemp-insert-cxx-syntax ()
"Insert C++ syntax around each template class and function.
(while (re-search-forward "^.+" nil t)
(progn
(beginning-of-line)
- (insert "template class ")))
+ (if (looking-at "struct[\\t ]+\\|class[\\t ]+")
+ (insert "template ")
+ (insert "template class "))))
(goto-char (point-min))
(message "Inserting 'template' for functions")
(while (re-search-forward
(progn
(beginning-of-line)
(forward-word 1)
- (kill-word 1)))))
+ (delete-region (point) (progn (forward-word 1) (point)))))))
(defun mantemp-make-mantemps ()
"Gathering interface to the functions modifying the buffer."
See the commentary in file mantemp.el for an example of use."
(interactive)
(mantemp-make-mantemps)
- (message "mantemp-make-mantemps-buffer is done"))
+ (message "Done"))
(defun mantemp-make-mantemps-region ()
"Make manual template instantiations from g++ error messages in the region.
-This function does the same as
-'mantemp-make-mantemps-buffer' but operates on the region."
+This function does the same thing as `mantemp-make-mantemps-buffer',
+but operates on the region."
(interactive)
(let ((cur-buf (current-buffer))
- (mantemp-buffer (generate-new-buffer "*mantemp*")))
+ (mantemp-buffer (generate-new-buffer "*mantemp*"))
+ (str (buffer-substring (mark) (point))))
;; Copy the region to a temporary buffer, make the C++ code there
;; and copy the result back to the current buffer.
- (kill-region (mark) (point))
(set-buffer mantemp-buffer)
- (yank)
+ (insert str)
(mantemp-make-mantemps)
- (kill-region (point-min) (point-max))
+ (setq str (buffer-string))
(set-buffer cur-buf)
- (yank)
+ (insert str)
(kill-buffer mantemp-buffer))
- (message "mantemp-make-mantemps-region is done"))
+ (message "Done"))
(provide 'mantemp)
+;; arch-tag: 49794712-3b1b-4baa-9785-39556cb52c94
;;; mantemp.el ends here