1 ;;; frsh-forb.el --- Helper functions for editing FRSH/FORB sources
3 ;; Copyright (C) 2010 Michal Sojka
5 ;; Author: Michal Sojka <sojkam1@fel.cvut.cz>
6 ;; Keywords: c, files, convenience
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
27 (defun update-fres-error-c ()
28 "When called from fres_error.h it updates fres_error.c to match
29 the list if defined errors"
33 (re-search-forward "^enum fres_error \{")
42 (narrow-to-region beg end)
43 (goto-char (point-min))
44 (while (re-search-forward "^[[:space:]]*FRES_ERR_" nil t)
45 (push (current-word) errors)))
47 (set-buffer (find-file-noselect "fres_error.c"))
49 (search-forward "switch (e) {")
50 (kill-region (point) (save-excursion (search-forward "}") (backward-char) (point)))
55 (indent-according-to-mode)
57 (insert (concat "MSG(" (replace-regexp-in-string "^FRES_ERR_" "" e) ");"))
58 (indent-according-to-mode)
59 (beginning-of-line)))))
60 (message "fres_error.c updated")))
65 ;;; frsh-forb.el ends here