4 A Programmer's Text Editor
6 A simple IDE-like build system.
8 Copyright (C) 1991-2011 Angel Ortega <angel@triptico.com>
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 http://www.triptico.com
28 /** editor actions **/
30 mp.actions['build'] = sub(doc) {
34 if ((t = mp.build_get_targets()) == NULL)
35 mp.alert(L("No Makefile targets found."));
37 /* more than one target? ask user to pick one */
42 label: L("Makefile target") ~ ':',
45 value: mp.makefile_target
51 mp.makefile_target = r[0];
53 if (mp.makefile_target == 0)
56 target = t[mp.makefile_target];
61 mp.long_op(mp.build_execute, target);
66 mp.actions['insert_next_item'] = sub(doc) {
69 foreach (l, doc.txt.lines) {
70 local r = regex(l, ['/^ \* /', '/[0-9]+/', '/: /']);
77 mp.insert(doc, ' * ' ~ (n + 1) ~ ': ');
80 /** Default key bindings **/
82 mp.keycodes['f2'] = "build";
84 /** action descriptions **/
86 mp.actdesc['build'] = LL("Build project...");
87 mp.actdesc['insert_next_item'] = LL("Insert next item");
92 sub mp.build_get_targets
96 if ((f = open('Makefile', 'r')) != NULL) {
101 while (l = read(f)) {
104 if (t = regex(l, '/^[A-Za-z0-9_\.-]+:/'))
105 push(r, sregex(t, '/:/', ''));
115 sub mp.build_execute(target)
117 local log = mp.open('<make output>');
122 /* pipe through make */
124 if ((p = popen('make ' ~ target, 'r')) != NULL) {
135 log.syntax = mp.syntax.make_output;
139 /* set the last search regex to match file:line strings,
140 so that calling seek-next and seek-prev moves there */
141 mp.last_search = '/^[a-z\.\_0-9\/-]+:[0-9]+:/m';