diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2015-08-15 14:36:04 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2015-08-15 14:36:04 +0200 |
| commit | 6b2931f57e5514fe565fd4608e60c6f91c97fb6d (patch) | |
| tree | 456962e00a9cc13b2a7ec1adc348353572de6815 | |
| parent | f6f3e3bbfed0b250170d5d682e25f4ad7c5c511b (diff) | |
magit-shell-command{,-topdir}: new commands
| -rw-r--r-- | Documentation/RelNotes/2.2.0.txt | 2 | ||||
| -rw-r--r-- | Documentation/magit.org | 37 | ||||
| -rw-r--r-- | Documentation/magit.texi | 49 | ||||
| -rw-r--r-- | lisp/magit.el | 52 |
4 files changed, 103 insertions, 37 deletions
diff --git a/Documentation/RelNotes/2.2.0.txt b/Documentation/RelNotes/2.2.0.txt index 52b3e8d..302d6ac 100644 --- a/Documentation/RelNotes/2.2.0.txt +++ b/Documentation/RelNotes/2.2.0.txt @@ -164,6 +164,8 @@ Changes since v2.1.0 * New face `magit-section-secondary-heading'. +* New commands `magit-shell-command' and `magit-shell-command-topdir'. + This release also contains various documentation fixes, code clean-ups, bug fixes, and other small to medium improvements. diff --git a/Documentation/magit.org b/Documentation/magit.org index fe18abb..11bd68c 100644 --- a/Documentation/magit.org +++ b/Documentation/magit.org @@ -979,31 +979,46 @@ switch to a shell. - Key: !, magit-run-popup - Show the popup buffer featuring the below suffix commands. + Shows the popup buffer featuring the below suffix commands. + +These suffix commands run a Git subcommand. The user input has to +begin with the subcommand, "git" is assumed. - Key: ! !, magit-git-command-topdir - Execute a Git subcommand asynchronously, displaying the output. + This command reads a Git subcommand from the user and executes it in + the top-level directory of the current repository. - With a prefix argument run Git in the root of the current - repository. +- Key: ! p, magit-git-command + + This command reads a Git subcommand from the user and executes it in + ~default-directory~. With a prefix argument the command is executed + in the top-level directory of the current repository instead. + +These suffix commands run arbitrary shell commands. + +- Key: ! !, magit-shell-command-topdir + + This command reads a shell command from the user and executes it in + the top-level directory of the current repository. -- Key: ! :, magit-git-command +- Key: ! p, magit-shell-command - Execute a Git subcommand asynchronously, displaying the output. - Run Git in the top-level directory of the current repository. + This command reads a shell command from the user and executes it in + ~default-directory~. With a prefix argument the command is executed + in the top-level directory of the current repository instead. -This popup also features some commands that start external gui tools. +These suffix commands start external gui tools. - Key: ! g, magit-run-git-gui - Run ~git gui~ for the current git repository. + Runs ~git gui~ for the current git repository. - Key: ! k, magit-run-gitk - Run Gitk for the current git repository. + Runs Gitk for the current git repository. - Run ~gitk --all~. With a prefix argument run gitk without any + Runs ~gitk --all~. With a prefix argument run gitk without any arguments. *** Git executable diff --git a/Documentation/magit.texi b/Documentation/magit.texi index d193ebe..b9a5474 100644 --- a/Documentation/magit.texi +++ b/Documentation/magit.texi @@ -1368,41 +1368,64 @@ switch to a shell. @cindex magit-run-popup @item @kbd{!} @tie{}@tie{}@tie{}@tie{}(@code{magit-run-popup}) -Show the popup buffer featuring the below suffix commands. +Shows the popup buffer featuring the below suffix commands. +@end table + +These suffix commands run a Git subcommand. The user input has to +begin with the subcommand, "git" is assumed. +@table @asis @kindex ! ! @cindex magit-git-command-topdir @item @kbd{! !} @tie{}@tie{}@tie{}@tie{}(@code{magit-git-command-topdir}) -Execute a Git subcommand asynchronously, displaying the output. +This command reads a Git subcommand from the user and executes it in +the top-level directory of the current repository. -With a prefix argument run Git in the root of the current -repository. - -@kindex ! : +@kindex ! p @cindex magit-git-command -@item @kbd{! :} @tie{}@tie{}@tie{}@tie{}(@code{magit-git-command}) +@item @kbd{! p} @tie{}@tie{}@tie{}@tie{}(@code{magit-git-command}) + +This command reads a Git subcommand from the user and executes it in +@code{default-directory}. With a prefix argument the command is executed +in the top-level directory of the current repository instead. +@end table + +These suffix commands run arbitrary shell commands. + +@table @asis +@kindex ! ! +@cindex magit-shell-command-topdir +@item @kbd{! !} @tie{}@tie{}@tie{}@tie{}(@code{magit-shell-command-topdir}) + +This command reads a shell command from the user and executes it in +the top-level directory of the current repository. + +@kindex ! p +@cindex magit-shell-command +@item @kbd{! p} @tie{}@tie{}@tie{}@tie{}(@code{magit-shell-command}) -Execute a Git subcommand asynchronously, displaying the output. -Run Git in the top-level directory of the current repository. +This command reads a shell command from the user and executes it in +@code{default-directory}. With a prefix argument the command is executed +in the top-level directory of the current repository instead. @end table -This popup also features some commands that start external gui tools. +These suffix commands start external gui tools. @table @asis @kindex ! g @cindex magit-run-git-gui @item @kbd{! g} @tie{}@tie{}@tie{}@tie{}(@code{magit-run-git-gui}) -Run @code{git gui} for the current git repository. +Runs @code{git gui} for the current git repository. @kindex ! k @cindex magit-run-gitk @item @kbd{! k} @tie{}@tie{}@tie{}@tie{}(@code{magit-run-gitk}) -Run Gitk for the current git repository. +Runs Gitk for the current git repository. -Run @code{gitk --all}. With a prefix argument run gitk without any +Runs @code{gitk --all}. With a prefix argument run gitk without any arguments. @end table diff --git a/lisp/magit.el b/lisp/magit.el index c541a74..08f7f9e 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -1987,20 +1987,22 @@ Currently this only adds the following key bindings. (magit-define-popup magit-run-popup "Popup console for running raw Git commands." 'magit-commands nil nil - :actions '((?! "Git Subcommand (from root)" magit-git-command-topdir) - (?: "Git Subcommand (from pwd)" magit-git-command) - (?g "Git Gui" magit-run-git-gui) - (?k "Gitk" magit-run-gitk)) - :default-action 'magit-git-command) + :actions '((?! "Git Subcommand (in topdir)" magit-git-command-topdir) + (?k "Gitk" magit-run-gitk) + (?p "Git Subcommand (in pwd)" magit-git-command) + (?g "Git Gui" magit-run-git-gui) + (?s "Shell command (in topdir)" magit-shell-command-topdir) + nil + (?S "Shell command (in pwd)" magit-shell-command)) + :default-action 'magit-git-command + :max-action-columns 2) ;;;###autoload (defun magit-git-command (args directory) "Execute a Git subcommand asynchronously, displaying the output. With a prefix argument run Git in the root of the current -repository, otherwise in `default-directory'. - -Non-interactively run Git in DIRECTORY with ARGS." - (interactive (magit-git-command-read-args)) +repository, otherwise in `default-directory'." + (interactive (magit-read-shell-command "Git subcommand (pwd: %s)")) (require 'eshell) (with-temp-buffer (insert args) @@ -2011,20 +2013,44 @@ Non-interactively run Git in DIRECTORY with ARGS." (magit-mode-display-buffer (magit-process-buffer directory t) 'magit-process-mode 'pop-to-buffer)) +;;;###autoload (defun magit-git-command-topdir (args directory) "Execute a Git subcommand asynchronously, displaying the output. Run Git in the top-level directory of the current repository. \n(fn)" ; arguments are for internal use - (interactive (magit-git-command-read-args t)) + (interactive (magit-read-shell-command "Git subcommand (pwd: %s)" t)) + (magit-git-command args directory)) + +;;;###autoload +(defun magit-shell-command (args directory) + "Execute a shell command asynchronously, displaying the output. +With a prefix argument run the command in the root of the current +repository, otherwise in `default-directory'." + (interactive (magit-read-shell-command "Shell command (pwd: %s)")) + (require 'eshell) + (with-temp-buffer + (insert args) + (setq args (mapcar 'eval (eshell-parse-arguments (point-min) + (point-max)))) + (setq default-directory directory) + (apply #'magit-start-process (car args) nil (cdr args))) + (magit-mode-display-buffer (magit-process-buffer directory t) + 'magit-process-mode 'pop-to-buffer)) + +;;;###autoload +(defun magit-shell-command-topdir (args directory) + "Execute a shell command asynchronously, displaying the output. +Run the command in the top-level directory of the current repository. +\n(fn)" ; arguments are for internal use + (interactive (magit-read-shell-command "Shell command (pwd: %s)" t)) (magit-git-command args directory)) -(defun magit-git-command-read-args (&optional root) +(defun magit-read-shell-command (prompt &optional root) (let ((dir (if (or root current-prefix-arg) (or (magit-toplevel) (user-error "Not inside a Git repository")) (expand-file-name default-directory)))) - (list (magit-read-string (format "Git subcommand (in %s)" - (abbreviate-file-name dir)) + (list (magit-read-string (format prompt (abbreviate-file-name dir)) nil 'magit-git-command-history) dir))) |
