0

How can I programmatically set the same argument (e.g., --gpg-sign=abc123) for multiple transient-values? If I try the following, it seems that the value of adamliter/my-gpg-key-sign-git-arg does not get expanded.

(setq adamliter/my-gpg-key "abc123")
(setq adamliter/my-gpg-key-sign-git-arg (format "--gpg-sign=%s" adamliter/my-gpg-key))
(setq transient-values
      '(
        (magit-commit adamliter/my-gpg-key-sign-git-arg)
        (magit-fetch "--prune")
        (magit-merge adamliter/my-gpg-key-sign-git-arg)
        (magit-rebase "--autostash" adamliter/my-gpg-key-sign-git-arg)
        (magit-revert "--edit" adamliter/my-gpg-key-sign-git-arg)
        )
      )

After evaluating this, the value of transient-values is:

((magit-commit adamliter/my-gpg-key-sign-git-arg)
 (magit-fetch "--prune")
 (magit-merge adamliter/my-gpg-key-sign-git-arg)
 (magit-rebase "--autostash" adamliter/my-gpg-key-sign-git-arg)
 (magit-revert "--edit" adamliter/my-gpg-key-sign-git-arg))

But I would expect it to be:

((magit-commit "--gpg-sign=abc123")
 (magit-fetch "--prune")
 (magit-merge "--gpg-sign=abc123")
 (magit-rebase "--autostash" "--gpg-sign=abc123")
 (magit-revert "--edit" "--gpg-sign=abc123"))

Thanks in advance for the help. I'm not too familiar with Emacs Lisp, so assume I'm just making a simple mistake here.

Adam Liter
  • 143
  • 6
  • 2
    Does this post (https://emacs.stackexchange.com/q/7481/253) answer your question? – Dan Sep 02 '23 at 16:32
  • 2
    This is a dup: see the top answer to https://emacs.stackexchange.com/questions/72261/my-org-mode-capture-code-returns-invalid-file-location-nil/72289#72289. Long story short: look up `backquote`. – Fran Burstall Sep 02 '23 at 16:34
  • https://emacs.stackexchange.com/tags/elisp/info – Drew Sep 02 '23 at 21:43
  • Yes, thank you. Sorry I didn't find that question when looking. Happy to close it as a dupe of [How to evaluate the variables before adding them to a list?](https://emacs.stackexchange.com/questions/7481/how-to-evaluate-the-variables-before-adding-them-to-a-list). Will just say as someone not that familiar with `elisp`, it wasn't obvious to me which part needed the backtick. Took me a bit of experimenting to figure it out, but it needs to be `\`((magit-commit ,adamliter/my-gpg-key-sign-git-arg))`. Thank you! – Adam Liter Sep 03 '23 at 00:12

0 Answers0