lode leroy,
The following might do roughly what you want.
(defun recompile-current-line ()
"Rerun the command on the current line in the ~/build directory."
(interactive)
(let* ((line-text (buffer-substring-no-properties
(line-beginning-position)
(line-end-position)))
(compile-command (concat "cd ~/build && " line-text)))
(shell-command compile-command)))
There are probably a couple things worth doing if you expect to have more tasks that need automation.
1. Learn emacs lisp. (You've already hinted at this. The next steps should help you with this.)
2. Name, save, study and edit your keyboard macros. (More below.)
3. Read the introduction to emacs lisp, `info "Emacs Lisp Intro"' brings it up. The table of contents alone gives a good idea of what is possible.
4. Use steps 2 & 3 to learn emacs lisp.
Regarding keyboard macros: `C-x C-k e' brings up special buffer for editing keyboard macros. It also contains hints (sometimes wrong unfortunately) about the corresponding lisp functions involved. Here's one that inserts "foo" with some corrections.
Macro:
f ;; self-insert-command
ooo ;; self-insert-command * 3
C-b ;; backward-char
C-k ;; kill-line
C-n ;; next-line
The corresponding elisp functions are on the right. They suggest the following function definition:
(defun insert-foo-extravagantly ()
"Insert `foo' extravagantly with some mistakes."
(interactive)
(insert "fooo")
(backward-char)
(kill-line)
(next-line))
I hope this helps.
,Douglas
Douglas Lewan
Shubert Ticketing
(201) 489-8600 ext 224
Journalism is printing what someone else does not want printed. Everything else is public relations. - George Orwell