this post was submitted on 16 Oct 2023
1 points (66.7% liked)

Emacs

313 readers
3 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I'm trying to make my Emacs configuration more reproducible, in part by creating variables with paths to packages, directories which depend on what machine I'm on:

(if my/laptop-p
    (progn
      ...
      (defvar my/mu4e-dir            "/usr/share/emacs/site-lisp/mu4e"
  "Location of local `mu4e' files installed by system package manager")
      ...
                ))

 

Here, my/laptop-p tests if (equal (system-name) "my-thinkpad").

This system works well, so that for the relevant example of mu4e (which is apparently quite tricky to set up in straight.el ) I can use:

(use-package mu4e
  :straight
  (:local-repo my/mu4e-dir
               :type built-in)
               ...
               )

 

The package loads and the configuration works fine.

But doing straight-freeze-versions gives:

straight--dir: Wrong type argument: stringp, my/mu4e-dir

This can be fixed by replacing my/mu4e-dir with the string "/usr/share/emacs/site-lisp/mu4e", but I'd like to avoid this if I can.

  Is there a way I can keep using my defined variable my/mu4e-dir instead of the full path name?

you are viewing a single comment's thread
view the rest of the comments
[–] nv-elisp@alien.top 1 points 1 year ago

Is there a way I can keep using my defined variable

https://www.gnu.org/software/emacs/manual/html_node/elisp/Backquote.html

As a side note, it would be better to set your variable like so:

(defvar my/mu4e-dir
  (cond ((my/laptop-p) "path/to/it")
      ;;etc

The way you're doing it in your example seems inverted.