[
    {
        "role": "user",
        "content": "if%20I%27m%20running%20emacs%2030%2C%20I%20can%20use%20--init-dir%20command%20line%20option.%20what%20is%20equivalent%20in%20prior%20versions%20of%20emacs%3F"
    },
    {
        "role": "assistant",
        "content": "In Emacs 29 and 30, there's a built-in command-line option `--init-directory` (also `--init-dir`) that lets you override `user-emacs-directory` directly. ([emacsredux.com](https://emacsredux.com/blog/2024/02/23/changing-the-emacs-configuration-directory/?utm_source=openai))\n\nIf you\u2019re using a version *prior* to Emacs 29, there is no native `--init-dir` or equivalent command-line flag. However, there *are* other ways to approximate or replicate this behavior. Here are the options:\n\n---\n\n### \u2714 Existing built-in options before `--init-dir`\n\nThese apply in Emacs versions before 29:\n\n| Option | What it does | Useful for switching init files/directories? |\n|---|---|---|\n| `-q` / `--no-init-file` | Skip loading any user init file. ([gnu.org](https://www.gnu.org/s/emacs/manual/html_node/elisp/Init-File.html?utm_source=openai)) | Good if you want to start from scratch. |\n| `-l FILE` / `--load FILE` | After startup, load a specific Lisp file. ([emacs.stackexchange.com](https://emacs.stackexchange.com/questions/78691/emacs-wont-load-my-config-emacs-init-el-unless-i-do-this?utm_source=openai)) | You can load an alternate config file. But it doesn\u2019t change where Emacs believes its `user-emacs-directory` is. |\n\nAlso:\n\n- The `-u USER` (or `--user USER`) option allows Emacs to load **another user\u2019s** init file. That is, Emacs treats your init file as if it were that user\u2019s. ([gnu.org](https://www.gnu.org/s/emacs/manual/html_node/elisp/Init-File.html?utm_source=openai))  \n- You can set environment variables like `HOME` or `XDG_CONFIG_HOME` to redirect where Emacs looks for its init file or config directory. ([xahlee.info](https://xahlee.info/emacs/emacs/emacs_where_is_init_file.html?utm_source=openai))\n\n---\n\n### \u26a0 What you *can\u2019t* do (pre-Emacs 29)\n\nThese are things which the old versions don\u2019t support directly:\n\n- You *can\u2019t* tell Emacs \u201cfor this session, treat `/some/path` as your `.emacs.d`\u201d. That is exactly what `--init-dir` does, and this is a new feature in Emacs 29. ([microblog.desipenguin.com](https://microblog.desipenguin.com/post/emacs-init-dir/?utm_source=openai))  \n- Changing `user-emacs-directory` from the command line in older versions typically requires hacks or wrapper scripts.\n\n---\n\n### \ud83d\udd27 Workarounds for older Emacs versions\n\nHere are some ways people approximate `--init-dir` before Emacs 29:\n\n- **Wrapper script**: create a shell script that sets `HOME` (or `XDG_CONFIG_HOME`) to a custom directory, then launches Emacs. Since Emacs uses `HOME` to determine `user-emacs-directory`, this effectively changes where config files are read from.  \n- **Use `emacs -q --load /path/to/other/init.el`**: skip your normal init, then load a specific init file. Effective but not identical: you\u2019d miss earlier startup hooks, some defaults, and Emacs won\u2019t treat that file as *the* init file in terms of some variables. ([stackoverflow.com](https://stackoverflow.com/questions/17146844/is-there-a-way-to-specify-custom-init-file-on-emacs-startup?utm_source=openai))  \n- **Symlink substitution**: rename your `.emacs.d` (or `.emacs`, etc.) and replace it with a symlink to whichever config directory you want to use in that session. This is manually switching where Emacs reads from.  \n\n---\n\n### \u2705 Summary\n\n- In **Emacs 29+**, you can use `--init-directory=DIR` (or `--init-dir`) to change `user-emacs-directory`.  \n- In **older versions**, there is *no single built-in flag* that does exactly that. You\u2019ll need to simulate it using `-q` + `--load`, environment variables, symlinks, or wrapper scripts.  \n\nIf you tell me which specific older version you're using (e.g. Emacs 26, 27, 28), I can show you a concrete workaround that fits best for that version."
    }
]