How to use-package :custom with a variable in an alist?

Table of Contents

Intro

What I’m trying to do should be obvious from this code:

(use-package undo-tree
    :custom
  (undo-tree-history-directory-alist '(("." . (concat user-emacs-directory "Undo")))))

But I had trouble getting the syntax right, since use-package is already performing some types of quoting at certain levels.

Solution

the key was in the proper locations of the syntax-quoote ` and splice , operators. The syntax quote was easy; just swap the reqular quote for it. The splicing operator appears in the location of minimal change, just before the function call that is going to use produce code based on an external variable.

(use-package undo-tree   
         :delight undo-tree-mode
         :bind (("C-x /" . undo-tree-visualize))
         :custom
         (undo-tree-history-directory-alist `(("." . ,(concat user-emacs-directory "Undo"))))
         :config         
         (global-undo-tree-mode t))
Tory Anderson avatar
Tory Anderson
Full-time Web App Engineer, Digital Humanist, Researcher, Computer Psychologist