]> git.eshelyaron.com Git - emacs.git/commitdiff
Add commands to run shell commands in project root
authorStefan Kangas <stefankangas@gmail.com>
Fri, 28 Aug 2020 17:23:01 +0000 (19:23 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Fri, 28 Aug 2020 17:27:47 +0000 (19:27 +0200)
* lisp/progmodes/project.el (project-async-shell-command)
(project-shell-command): New commands to run 'async-shell-command'
and 'shell-command' in project's root directory.
(project-prefix-map): Bind commands to '!' and '&'.
* doc/emacs/maintaining.texi (Project File Commands): Document the
new commands.
* etc/NEWS: Announce the new commands.

doc/emacs/maintaining.texi
etc/NEWS
lisp/progmodes/project.el

index 9f550b498741876fd43fae352e4b94c203283317..a9b0da5aff64dd3ddd34f6e594cde1cf535a2a3e 100644 (file)
@@ -1693,6 +1693,12 @@ Start Eshell in the current project's root directory
 @item C-x p c
 Run compilation in the current project's root directory
 (@code{project-compile}).
+@item C-x p !
+Run shell command in the current project's root directory
+(@code{project-shell-command}).
+@item C-x p &
+Run shell command asynchronously in the current project's root
+directory (@code{project-async-shell-command}).
 @end table
 
   Emacs provides commands for handling project files conveniently.
@@ -1770,6 +1776,14 @@ directory.  @xref{Top,Eshell,Eshell, eshell, Eshell: The Emacs Shell}.
   The command @kbd{C-x p c} (@code{project-compile}) runs compilation
 (@pxref{Compilation}) in the current project's root directory.
 
+@findex project-shell-command
+  The command @kbd{C-x p !} (@code{project-shell-command}) runs
+@code{shell-command} in the current project's root directory.
+
+@findex project-async-shell-command
+  The command @kbd{C-x p &} (@code{project-async-shell-command}) runs
+@code{async-shell-command} in the current project's root directory.
+
 @node Project Buffer Commands
 @subsection Project Commands That Operate on Buffers
 
index 964b626d7b8f112fe5982b1a7280cb8d4e8ae0c8..658e2a35d7656afc5f8b3879bc8f26e97ddb1a10 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -778,6 +778,11 @@ directory.
 This command lets you "switch" to another project and run a project
 command chosen from a dispatch menu.
 
++++
+*** New commands 'project-shell-command' and 'project-async-shell-command'.
+These commands run 'shell-command' and 'async-shell-command' in a
+project's root directory, respectively.
+
 +++
 *** New user option 'project-list-file'.
 
index 8afd5ce7959344bfa738d58ecf79ee87d3a7b273..4fae3e9186cadb56d6b202b82404fd3537867ec2 100644 (file)
@@ -581,6 +581,8 @@ DIRS must contain directory names."
 ;;;###autoload
 (defvar project-prefix-map
   (let ((map (make-sparse-keymap)))
+    (define-key map "!" 'project-shell-command)
+    (define-key map "&" 'project-async-shell-command)
     (define-key map "f" 'project-find-file)
     (define-key map "F" 'project-or-external-find-file)
     (define-key map "b" 'project-switch-to-buffer)
@@ -882,6 +884,20 @@ if one already exists."
         (pop-to-buffer eshell-buffer)
       (eshell t))))
 
+;;;###autoload
+(defun project-async-shell-command ()
+  "Run `async-shell-command' in the current project's root directory."
+  (interactive)
+  (let ((default-directory (project-root (project-current t))))
+    (call-interactively #'async-shell-command)))
+
+;;;###autoload
+(defun project-shell-command ()
+  "Run `shell-command' in the current project's root directory."
+  (interactive)
+  (let ((default-directory (project-root (project-current t))))
+    (call-interactively #'shell-command)))
+
 (declare-function fileloop-continue "fileloop" ())
 
 ;;;###autoload