CompileInsideScratchbox

It’s quite easy to use emacs for development inside scratchbox. The situation is as follows:

First thing you need to do is make sure that your can reach your code through the same path. That usually means that the source code dir in your ‘normal’ linux environment is a symlink to the one inside scratchbox, for example:

$ ln -s /scratchbox/users/djcb/home/djcb/src/foo /home/djcb/src/foo

Now, it’s quite easy to add a function to your .emacs:

;; compile inside scratchbox
(defun scratchbox-c-mode-compile ()
   (interactive)
   (compile (concat "scratchbox make -C " default-directory)))

Now, in my case it’s even a bit harder, as I am running an AMD/64 machine, and have scratchbox installed in a 32-bit chroot. Of course, it’s easy to teach emacs about the extra indirection:

;; for amd64, with scratchbox in a chroot
(defun scratchbox-c-mode-compile ()
   (interactive)
   (compile (concat "dchroot "
     "\"scratchbox make -C " default-directory "\"")))

Now you can run emacs in your normal linux environment, and open a file in ~/src/foo/..., and compile it inside scratchbox with M-x scratchbox-c-mode-compile; or even better, connect to some function key:

  (define-key c-mode-base-map (kbd "<f8>")  'scratchbox-c-mode-compile)

And pressing F8 is enough to compile all that beautiful code…


CategoryProgrammerUtils