Add gac-shell-or, gac-shell-begin, gac-shell-end

This commit is contained in:
Robert Irelan 2020-02-04 15:17:24 -08:00
parent 47d2d5f379
commit f89ed36c38
2 changed files with 57 additions and 5 deletions

View file

@ -94,10 +94,31 @@
made, but not the file from being saved. made, but not the file from being saved.
- =gac-shell-and= :: - =gac-shell-and= ::
A string that can be used to change how the shell combines commands. The A string that can be used to change how the shell combines commands like
~CMD1 AND CMD2~, where CMD2 should only be run if CMD1 succeeds. The
default " && " is good for bash-like shells, but " ; and " would be used for default " && " is good for bash-like shells, but " ; and " would be used for
fish, for example. fish, for example.
- =gac-shell-or= ::
A string that can be used to change how the shell combines commands like
~CMD1 OR CMD2~, where CMD2 should only be run if CMD1 doesn't succeed. The
default " || " is good for bash-like shells, but " ; or " would be used for
fish, for example.
- =gac-shell-begin= ::
A string that can be used to change how the shell starts chains of commands
like ~BEGIN CMD1; CMD2 END~, where CMD1 and CMD2 are both run and where
the exit status of the chain is the exit status of CMD2. The default
" { " is good for bash-like shells, but " begin " would be used for
fish, for example.
- =gac-shell-end= ::
A string that can be used to change how the shell ends chains of commands
like ~BEGIN CMD1; CMD2 END~, where CMD1 and CMD2 are both run and where
the exit status of the chain is the exit status of CMD2. The default
" ; } " is good for bash-like shells, but " ; end " would be used for
fish, for example.
- =gac-debounce-interval= :: - =gac-debounce-interval= ::
A number specifying a buffer between automatic commits in seconds. Wait with A number specifying a buffer between automatic commits in seconds. Wait with
making an actual commit until this number of seconds elapses. making an actual commit until this number of seconds elapses.

View file

@ -96,8 +96,35 @@ changes made since the current file was loaded."
:type 'boolean) :type 'boolean)
(defcustom gac-shell-and " && " (defcustom gac-shell-and " && "
"How to join commands together in the shell. For fish shell, "The syntax to use for CMD1 AND CMD2, where CMD2 should only be run if CMD1
you want to customise this to: \" ; and \" instead of the default." is successful. For fish shell, you want to customise this to: \" ; and \"
instead of the default."
:tag "Join shell commands"
:group 'git-auto-commit-mode
:type 'string)
(defcustom gac-shell-or " || "
"The syntax to use for CMD1 OR CMD2, where CMD2 should only be run if CMD1
is not successful. For fish shell, you want to customise this to: \" ; and \"
instead of the default."
:tag "Join shell commands"
:group 'git-auto-commit-mode
:type 'string)
(defcustom gac-shell-begin " { "
"The syntax to use for BEGIN in BEGIN CMD1; CMD2; END, where CMD2 should be
run after CMD1 and the whole expression return the exit code of CMD2.
For fish shell, you want to customise this to: \" begin \"
instead of the default."
:tag "Join shell commands"
:group 'git-auto-commit-mode
:type 'string)
(defcustom gac-shell-end " ; } "
"The syntax to use for END in BEGIN CMD1; CMD2 END, where CMD2 should be
run after CMD1 and the whole expression return the exit code of CMD2.
For fish shell, you want to customise this to: \" ; end \"
instead of the default."
:tag "Join shell commands" :tag "Join shell commands"
:group 'git-auto-commit-mode :group 'git-auto-commit-mode
:type 'string) :type 'string)
@ -274,8 +301,12 @@ Standard error is inserted into a temp buffer if it's generated."
gac-shell-and gac-shell-and
;; Check if working directory is clean before attempting to ;; Check if working directory is clean before attempting to
;; commit; if it is, `git commit` will exit with exit code 1. ;; commit; if it is, `git commit` will exit with exit code 1.
"{ git diff --exit-code && git diff --cached --exit-code; }" gac-shell-begin
"||" "git diff --exit-code"
gac-shell-and
"git diff --cached --exit-code"
gac-shell-end
gac-shell-or
"git commit -m " (shell-quote-argument commit-msg))))) "git commit -m " (shell-quote-argument commit-msg)))))
(defun gac-merge (buffer) (defun gac-merge (buffer)