]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blob - src/frsh-forb.el
forb: script invocation of shlibs fixec
[frescor/frsh-forb.git] / src / frsh-forb.el
1 ;;; frsh-forb.el --- Helper functions for editing FRSH/FORB sources
2
3 ;; Copyright (C) 2010  Michal Sojka
4
5 ;; Author: Michal Sojka <sojkam1@fel.cvut.cz>
6 ;; Keywords: c, files, convenience
7
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.
12
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.
17
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/>.
20
21 ;;; Commentary:
22
23 ;; 
24
25 ;;; Code:
26
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"
30   (save-excursion
31     (beginning-of-buffer)
32     (let* ((beg (progn
33                   (re-search-forward "^enum fres_error \{")
34                   (beginning-of-line 2)
35                   (point)))
36            (end (progn
37                   (search-forward "}")
38                   (beginning-of-line)
39                   (point))))
40       (let ((errors))
41         (save-restriction
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)))
46         (save-current-buffer
47           (set-buffer (find-file-noselect "fres_error.c"))
48           (beginning-of-buffer)
49           (search-forward "switch (e) {")
50           (kill-region (point) (save-excursion (search-forward "}") (backward-char) (point)))
51           (insert "\n")
52
53           (dolist (e errors)
54             (insert "\n")
55             (indent-according-to-mode)
56             (previous-line)
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")))
61
62
63
64 (provide 'frsh-forb)
65 ;;; frsh-forb.el ends here