1

I'm writing an emacs wrapper to a set of scripts that require a lot of config settings to run.

These can be variously environment variables, command line parameters and so forth. They should be user visible and tweakable. They will store things like a bunch of directory locations for data files and config switches to be passed into the underlying tool.

If these were fairly static options I'd make each option customizable and create a specific group to hold them, just like other emacs config.

The difference I have is that I may want to have several different configurations that I switch between regularly - perhaps several times a day.

It doesn't feel like making these customizable options is perhaps the right way to store them. To me customizable variables have a single copy stored and change infrequently (in my custom.el file)?

I could instead store all these values in a non-emacs solution such as an ini or yaml file and load the yaml as part of wrapper prior to executing the script.

But I was wondering if there is a more emacs-standard way of maintaining multiple custom configs that can easily be switched between?

The only thing I can think of is to use defvar with a * in the doc-string to make variables change-able using set-variable. This doesn't presume they are set in a specific place like the normal use of customize. However this is perhaps now deprecated in favour of customize?

I guess in this case each config file would be an e-lisp file setting each of these options. This doesn't feel much different from having the options as standard lisp global variables however.

Any advice or ideas how to achieve this? Perhaps custom is the right tool and I have misunderstood its purpose or there is something else?

  • I use a countdown timer (e.g., 3 sec.) whenever I start Emacs that asks me if I want to start with zero user configuration or the full monty. You could have a countdown timer that asks you whether to load config #1, #2, #3, #4, #5, #6 or a default of config #0. Then, just restart Emacs and select your preferred config with a number, or a letter, or just let the timer countdown regularly and load your default, or interrupt with a number/letter not specifically defined. reddit.com/r/emacs/comments/aw63ja/… – lawlist Jun 10 at 2:35
  • (This is kind of an opinion-based question, BTW.) – Drew Jun 10 at 2:39
  • FWIW, there is nothing wrt defcustom that implies that it is for things that change seldom. Customize is often a good way to change values on the fly, in fact, as you can see more info, especially if the variable type is complex or has multiple possibilities. defcustom gives you this or M-x set-variable, and it does type-control. – Drew Jun 10 at 2:39
  • 1
    Is it possible that directory-local variables could solve your problem? – phils Jun 10 at 3:33
  • 1
    If you want to be able to edit the option sets, then you might create a complex customize type comprising an alist where each value is a list of option sets, such that you could add or delete an entire option set at any time, or edit the individual values of an existing one. You could then write a command which prompted the user for an option set key, and applied all of its associated settings. – phils Jun 13 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.