​On Tue, Jan 13, 2015 at 10:01 AM, Nathan Froyd <nfr...@mozilla.com> wrote:

> On Tue, Jan 13, 2015 at 11:52 AM, Nick Fitzgerald <nfitzger...@mozilla.com
> > wrote:
>
>> For those of us using Emacs:
>>
>> I use M-x shell as my terminal, and when combined with
>> compilation-shell-minor-mode, I get the following goodies:
>
>
> FYI, you can use M-x compile (or at least a wrapper around it) with a bit
> of cleverness:
>
> (defun froydnj-build-mozilla-with-mozconfig (mozconfig target)
>   (let* ((objdir (shell-command-to-string
>                   (format "grep MOZ_OBJDIR %s | cut -f 2 -d =" mozconfig)))
>          ;; Use the first cd command so compile's intelligent setting of
>          ;; default-directory works to our advantage.  Use the second cd
>          ;; command so mach is invoked from the correct directory.
>          (compile-command (format "cd %s; cd %s; env MOZCONFIG=%s mach
> --log-no-times build %s"
>                                   (remove-if #'(lambda (x) (char-equal x
> ?\n))
>                                              objdir :from-end t :count 1)
>                                   froydnj-mozilla-srcdir
>                                   mozconfig
>                                   target)))
>     (compile compile-command)))
>
> This gets invoked from some machinery to choose which mozconfig (six
> different mozconfigs so far, full builds or "binaries" builds), but the
> idea should be clear.  By setting compilation-buffer-name-function
> appropriately, separate mozconfigs produce their compilation output in
> separate buffers, and one can avoid cluttering up shells with compilation
> output.
>
> -Nathan
>

I have my own compile function that I bind to C-c C-c, that uses the shell
buffer instead of the compilation buffer (I prefer to have it all
integrated in one place):

(defun clear-shell-buffer ()
  (interactive)
  (let ((comint-buffer-maximum-size 0))
    (comint-truncate-buffer)))

(defun my-compile (cmd)
  (interactive
   (list (compilation-read-command compile-command)))
  (if (get-buffer "*shell*")
      (switch-to-buffer-other-window "*shell*")
    (shell))
  (clear-shell-buffer)
  (end-of-buffer)
  (comint-kill-input)
  (insert cmd)
  (end-of-line)
  (comint-send-input)
  (unless (equal cmd (eval compile-command))
    (setq compile-command cmd)))

The first time you compile, you have to enter the compilation command:

  C-c C-c ./mach build subdir RET

But after that, the cmd is remembered and you can simply do:

  C-c C-c RET
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to