Feeds:
Posts
Comments

Posts Tagged ‘make’

Multiple Build Commands For Emacs

Alex Bennee left a comment on my dollar editor post:

I then open a number of separate emacs processes for each project I’m actively working on. I mainly do this as each project typically has it’s own make invocation.

I have a similar issue myself where my work projects require different commands but I prefer to avoid running multiple emacs instances if possible. It is not too difficult to fix. The idea is to detect the name of the file and run a different make command depending on which directory the file is in. This can be extended to as many different directories as necessary.

(setq compilation-scroll-output t)

(defun make-lib ()
  (compile "make-lib-cmd"))

(defun make-app ()
  (compile "make-app-cmd"))

(defun run-compile ()
  (interactive)
  (let ((file (buffer-file-name (current-buffer))))
    (cond ((not (stringp file))
           (error "[%s] is not a string.  Invalid buffer %s ?"
                  f (buffer-name)))
          ((string-match "/src/lib/" file) (make-lib))
          ((string-match "/src/app/" file) (make-app))
          (t (error "Invalid location %s" file)))))

(define-key c-mode-base-map [f7] 'run-compile)

Read Full Post »

Follow

Get every new post delivered to your Inbox.