Hi John,

John Shahid <[email protected]> writes:

> Hi all,
>
> Is there a way to customize the command that magit run when I commit,
> e.g. using `git ci' (a user defined alias) instead of `git commit' ?  I
> used to have a popup action to run `git ci' bound to "i".  With the
> recent switch to transient my customization broke as it used to rely on
> `magit-popup'.  I replaced my previous hack with the following advice:
>
>   (defun shahid/magit-replace-command (args)
>     (message "called with: %S " args)
>     (pcase-let ((`(,cmd . ,args) args))
>       (cond
>        ((string-equal cmd "commit") (cons "ci" args))
>        (t (cons cmd args)))))

Since you're going with pcase-let, you could simplify this to something
like (untested):

    (defun shahid/magit-replace-command (args)
      (message "called with: %S " args)
      (pcase args
        (`("commit" . ,rest) (cons "ci" rest))
        (_ args)))

>   (advice-add #'magit-run-git-with-editor
>               :filter-args
>               #'shahid/magit-replace-command)
>
> But I'm wondering if there is any interest in making the commands used
> by magit customizable ?

IMO an option for configuring subcommands isn't something Magit should
support.  I think the above use case is a good fit for advice.


-- 
Kyle

-- 
You received this message because you are subscribed to the Google Groups 
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to