Fork me on GitHub
#emacs
<
2022-05-10
>
practicalli-johnny12:05:43

Elisp help please. Is there a recommended way to use an environment variable when setting the location of my auth-sources? It seems auth-sources wants a quoted list of values, which means pulling out the environment variable and adding the filename isnt going to be evaluated. So the following doesnt quite work...

(setq auth-sources '((concat (getenv "XDG_CONFIG_HOME") "/authinfo.gpg")
                     "~/.authinfo.gpg"))
I guess I could just use the relative locations in the list
(setq auth-sources '("~/.config/authinfo.gpg" "~/.authinfo.gpg"))
But wonder if there is a nicer approach

magnars12:05:11

Try:

(setq auth-sources `((concat ,(getenv "XDG_CONFIG_HOME") "/authinfo.gpg")
                     "~/.authinfo.gpg"))

👍 1
magnars12:05:19

which is the fancy way to quote/unquote something

magnars12:05:23

even simpler:

(setq auth-sources (list
                    (concat (getenv "XDG_CONFIG_HOME") "/authinfo.gpg")
                    "~/.authinfo.gpg"))

practicalli-johnny12:05:00

ah, so , is unquoting and therefore the concat expression evaluates to a string, nice. I like the list approach, more obvious to me. Thank you.

👍 1
dakra14:05:40

Since Emacs 26 I think, instead of (getenv "XDG_CONFIG_HOME") you can require 'xdg package and call (xdg-config-home). It's basically just getenv plus a fallback to ~/.config, so probably doesn't matter much.

vemv12:05:50

I recently followed this tip from HN https://blog.nilbus.com/take-the-pain-out-of-git-conflict-resolution-use-diff3/ which is how I always wanted merge conflicts to be rendered. The cool part being, Emacs already understands this diff3 format OOTB. The new part is rendered in yellow: http://www.skybert.net/graphics/2017/2017-01-04-emacs-3-way-diff-git-merge.png highly recommended emacs

🙏 3
pavlosmelissinos13:05:20

That does look nice. Fwiw, I've always used ediff in emacs from a magit status buffer and it's similar to what you're showing but it also has each version in a separate buffer. I use n and p to go to the previous/next conflict and choose a (local), b (remote) or c (ancestor). Haven't used smerge though so not sure if I'm missing out on something...

💯 1
practicalli-johnny19:05:24

@U45T93RA6 so if I set

git config --global merge.conflictstyle diff3
then Emacs will show the common ancestor automatically when I have a merge conflict in magit? Or is there something else needed?

vemv20:05:18

I don't know for magit specifically, but yes, I had to do nothing in Emacs :)

practicalli-johnny07:05:04

So is the screenshot an example of ediff? Or something in the Emacs version control?

practicalli-johnny23:05:33

diff3 format shows in Magit status once merge.conflictstyle diff3 is set in the git config, nice

🙌 2