Compile-n-run in jed

In jed’s maling-list someone asked about how to compile and run from it without leave it. (Most of GUI IDEs do it.)
And you can automaticed it with a function that gets information about the buffer in which you are, runs the command and displays it on new buffer:

define compile_and_run ()
{
% declare variables
variable FORMAT = «cd %s && gcc -o %s %s && ./%s»;
variable filename, exe, dir, cmd, buffer;

% get file info and create command string
(filename, dir, , ) = getbuf_info ();
exe = path_basename_sans_extname (filename);
buffer = exe + «_output»;
cmd = sprintf (FORMAT, dir, exe, filename, exe);

% set output buffer, run command and move to that buffer
setbuf (buffer);
run_shell_cmd (cmd);
pop2buf (buffer);
}

Made it with charm and jed from a rxvt-unicode terminal.