unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Project.el - running processes in root
@ 2020-06-04 21:53 Theodor Thornhill
  2020-06-04 22:07 ` Dmitry Gutov
  0 siblings, 1 reply; 2+ messages in thread
From: Theodor Thornhill @ 2020-06-04 21:53 UTC (permalink / raw)
  To: emacs-devel


Hello!

What is the best way to run a subprocess in root of a project currently?

Right now I've made a small convenience macro for this:

(defmacro with-project-root (&rest body)
  "Dynamically bind default directory to project root."
  (declare (debug t) (indent 0))
  `(let ((default-directory (project-root (project-current))))
     ,@body))


Then I can:

(defun elm-repl ()
  "Create a new buffer with Elm repl started and switch to it."
  (interactive)
  (with-project-root
    (switch-to-buffer-other-window
     (make-comint "Elm Repl" "elm" nil "repl"))))

This seems like a nice solution, but if there already exists something like
this, please tell.  Otherwise, would this be something appropriate for
project.el to expose?

Have a nice day,

Theo




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Project.el - running processes in root
  2020-06-04 21:53 Project.el - running processes in root Theodor Thornhill
@ 2020-06-04 22:07 ` Dmitry Gutov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2020-06-04 22:07 UTC (permalink / raw)
  To: Theodor Thornhill, emacs-devel

Hello!

On 05.06.2020 00:53, Theodor Thornhill wrote:

> What is the best way to run a subprocess in root of a project currently?
> 
> Right now I've made a small convenience macro for this:
> 
> (defmacro with-project-root (&rest body)
>    "Dynamically bind default directory to project root."
>    (declare (debug t) (indent 0))
>    `(let ((default-directory (project-root (project-current))))
>       ,@body))
> 
> 
> Then I can:
> 
> (defun elm-repl ()
>    "Create a new buffer with Elm repl started and switch to it."
>    (interactive)
>    (with-project-root
>      (switch-to-buffer-other-window
>       (make-comint "Elm Repl" "elm" nil "repl"))))

It's as good a solution as any.

> Otherwise, would this be something appropriate for
> project.el to expose?

I'm not sure... It doesn't even save one line. Just shortens it.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-04 22:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 21:53 Project.el - running processes in root Theodor Thornhill
2020-06-04 22:07 ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).