Synch EDE to CEDET 1.0.
[emacs.git] / lisp / cedet / ede / srecode.el
blob3b131dd37538f2c69a4a1fb627adbc0e9b5bd31d
1 ;;; ede/srecode.el --- EDE utilities on top of SRecoder
3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; EDE utilities for using SRecode to generate project files, such as
25 ;; Makefiles.
27 (require 'srecode)
29 (declare-function srecode-create-dictionary "srecode/dictionary")
30 (declare-function srecode-dictionary-set-value "srecode/dictionary")
31 (declare-function srecode-load-tables-for-mode "srecode/find")
32 (declare-function srecode-table "srecode/find")
33 (declare-function srecode-template-get-table "srecode/find")
34 (declare-function srecode-insert-fcn "srecode/insert")
35 (declare-function srecode-resolve-arguments "srecode/insert")
36 (declare-function srecode-map-update-map "srecode/map")
38 ;;; Code:
39 (defun ede-srecode-setup ()
40 "Initialize Srecode for EDE."
41 (require 'srecode/map)
42 (require 'srecode/find)
43 (srecode-map-update-map t)
44 ;; We don't call this unless we need it. Load in the templates.
45 (srecode-load-tables-for-mode 'makefile-mode)
46 (srecode-load-tables-for-mode 'makefile-mode 'ede)
47 (srecode-load-tables-for-mode 'autoconf-mode)
48 (srecode-load-tables-for-mode 'autoconf-mode 'ede))
50 (defmacro ede-srecode-insert-with-dictionary (template &rest forms)
51 "Insert TEMPLATE after executing FORMS with a dictionary.
52 TEMPLATE should specify a context by using a string format of:
53 context:templatename
54 Locally binds the variable DICT to a dictionary which can be
55 updated in FORMS."
56 `(let* ((dict (srecode-create-dictionary))
57 (temp (srecode-template-get-table (srecode-table)
58 ,template
59 nil
60 'ede))
62 (when (not temp)
63 (error "EDE template %s for %s not found!"
64 ,template major-mode))
65 (srecode-resolve-arguments temp dict)
67 ;; Now execute forms for updating DICT.
68 (progn ,@forms)
70 (srecode-insert-fcn temp dict)
73 (defun ede-srecode-insert (template &rest dictionary-entries)
74 "Insert at the current point TEMPLATE.
75 TEMPLATE should specify a context by using a string format of:
76 context:templatename
77 Add DICTIONARY-ENTRIES into the dictionary before insertion.
78 Note: Just like `srecode-insert', but templates found in 'ede app."
79 (require 'srecode/insert)
80 (ede-srecode-insert-with-dictionary template
82 ;; Add in optional dictionary entries.
83 (while dictionary-entries
84 (srecode-dictionary-set-value dict
85 (car dictionary-entries)
86 (car (cdr dictionary-entries)))
87 (setq dictionary-entries
88 (cdr (cdr dictionary-entries))))
92 (provide 'ede/srecode)
94 ;; arch-tag: 75bec542-7cc8-41a4-b5a0-8fb247609f03
95 ;;; ede/srecode.el ends here