diff --git a/README.org b/README.org index 9929ee9..107ff74 100644 --- a/README.org +++ b/README.org @@ -94,10 +94,31 @@ made, but not the file from being saved. - =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 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= :: A number specifying a buffer between automatic commits in seconds. Wait with making an actual commit until this number of seconds elapses. diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 7a5127f..c73cb06 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -96,8 +96,35 @@ changes made since the current file was loaded." :type 'boolean) (defcustom gac-shell-and " && " - "How to join commands together in the shell. For fish shell, - you want to customise this to: \" ; and \" instead of the default." + "The syntax to use for CMD1 AND CMD2, where CMD2 should only be run if CMD1 + 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" :group 'git-auto-commit-mode :type 'string) @@ -274,8 +301,12 @@ Standard error is inserted into a temp buffer if it's generated." gac-shell-and ;; Check if working directory is clean before attempting to ;; 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))))) (defun gac-merge (buffer)