GithubHelp home page GithubHelp logo

chemacs2's Introduction

     ___           ___           ___           ___           ___           ___           ___
    /  /\         /__/\         /  /\         /__/\         /  /\         /  /\         /  /\
   /  /:/         \  \:\       /  /:/_       |  |::\       /  /::\       /  /:/        /  /:/_
  /  /:/           \__\:\     /  /:/ /\      |  |:|:\     /  /:/\:\     /  /:/        /  /:/ /\
 /  /:/  ___   ___ /  /::\   /  /:/ /:/_   __|__|:|\:\   /  /:/~/::\   /  /:/  ___   /  /:/ /::\
/__/:/  /  /\ /__/\  /:/\:\ /__/:/ /:/ /\ /__/::::| \:\ /__/:/ /:/\:\ /__/:/  /  /\ /__/:/ /:/\:\
\  \:\ /  /:/ \  \:\/:/__\/ \  \:\/:/ /:/ \  \:\~~\__\/ \  \:\/:/__\/ \  \:\ /  /:/ \  \:\/:/~/:/
 \  \:\  /:/   \  \::/       \  \::/ /:/   \  \:\        \  \::/       \  \:\  /:/   \  \2.0 /:/
  \  \:\/:/     \  \:\        \  \:\/:/     \  \:\        \  \:\        \  \:\/:/     \__\/ /:/
   \  \::/       \  \:\        \  \::/       \  \:\        \  \:\        \  \::/        /__/:/
    \__\/         \__\/         \__\/         \__\/         \__\/         \__\/         \__\/

                                        222222222222222
                                       2:::::::::::::::22
                                       2::::::222222:::::2
                                       2222222     2:::::2
                                                   2:::::2
                                                   2:::::2
                                                2222::::2
                                           22222::::::22
                                         22::::::::222
                                        2:::::22222
                                       2:::::2
                                       2:::::2
                                       2:::::2       222222
                                       2::::::2222222:::::2
                                       2::::::::::::::::::2
                                       22222222222222222222

Chemacs

Chemacs 2 is an Emacs profile switcher, it makes it easy to run multiple Emacs configurations side by side.

Think of it as a bootloader for Emacs.

Differences from Chemacs 1

Emacs intialization used to have a single entry point, either ~/.emacs or ~/.emacs.d/init.el. More recent Emacsen have introduced a second startup script, ~/.emacs.d/early-init.el, which runs earlier in the boot process, and can be used for things that should happen very early on, like tweaking the GC, or disabling UI elements.

Chemacs 2 supports early-init.el, Chemacs 1 does not. This does also imply that Chemacs 2 needs to be installed as ~/.emacs.d (a directory), rather than simply linking it to ~/.emacs (a single file).

Rationale

Emacs configuration is either kept in a ~/.emacs file or, more commonly, in a ~/.emacs.d directory. These paths are hard-coded. If you want to try out someone else’s configuration, or run different distributions like Prelude or Spacemacs, then you either need to swap out ~/.emacs.d, or run Emacs with a different $HOME directory set.

This last approach is quite common, but has some real drawbacks, since now packages will no longer know where your actual home directory is.

All of these makes trying out different Emacs configurations and distributions needlessly cumbersome.

Various approaches to solving this have been floated over the years. There’s an Emacs patch around that adds an extra command line option, and various examples of how to add a command line option in userspace from Emacs Lisp.

Chemacs tries to implement this idea in a user-friendly way, taking care of the various edge cases and use cases that come up.

Alternatives

Installation

Clone the Chemacs 2 repository as $HOME/.emacs.d. Note that if you already have an Emacs setup in ~/.emacs.d you need to move it out of the way first. If you have an ~/.emacs startup script then move that out of the way as well.

[ -f ~/.emacs ] && mv ~/.emacs ~/.emacs.bak
[ -d ~/.emacs.d ] && mv ~/.emacs.d ~/.emacs.default
git clone https://github.com/plexus/chemacs2.git ~/.emacs.d

Note that this is different from Chemacs 1. Before Chemacs installed itself as ~/.emacs and you could have your own default setup in ~/.emacs.d. This approach no longer works because of ~/.emacs.d/early-init.el, so Chemacs 2 needs to be installed as ~/.emacs.d.

Next you will need to create a ~/.emacs-profiles.el file, for details see below.

(("default" . ((user-emacs-directory . "~/.emacs.default"))))

Usage

Chemacs adds an extra command line option to Emacs, --with-profile. Profiles are configured in ~/.emacs-profiles.el.

If no profile is given at the command line then the environment variable CHEMACS_PROFILE is used. If this environment variables isn’t set then the default profile is used.

$ emacs --with-profile my-profile

There is an option for using profile that is not preconfigured in ~/.emacs-profiles.el. To accomplish that you can directly provide the profile via the command line, like so

$ emacs --with-profile '((user-emacs-directory . "/path/to/config"))'

This method supports all the profile options given below.

.emacs-profiles.el

This file contains an association list, with the keys/cars being the profile names, and the values/cdrs their configuration.

The main thing to configure is the user-emacs-directory

(("default" . ((user-emacs-directory . "~/.emacs.default")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs"))))

Chemacs will set this to be the user-emacs-directory in use, and load init.el from that directory.

Other things you can configure

  • custom-file : The file where Customize stores its customizations. If this isn’t configured, and the custom-file variable is still unset after loading the profile’s init.el, then this will get set to the profile’s init.el
  • server-name : Sets the server-name variable, so you can distinguish multiple instances with emacsclient -s <server-name>.
  • env An association list of environment variables. These will get set before loading the profile, so they can influence the initialization, and they are visible to any subprocesses spawned from Emacs.
  • straight-p Enable the Straight functional package manager.
  • nix-elisp-bundle A directory containing elisp dependencies bundled by the nix package manager. The bundle path can be produced by nix using an expression like (emacs.pkgs.withPackages (p: [ p.avy … ])).deps. Because the bundle path is in the nix store, if it is specified in .emacs-profiles.el then that file should also be maintained by nix, to prevent the path from being garbage-collected. Alternatively, a nix-generated script or alias could specify nix-elisp-bundle as a command-line argument.

Store .emacs-profiles.el together with your dotfiles. If you’re not yet keeping a version controlled directory of dotfiles, then check out connect-the-dots for a helpful script to do that.

Changing the default profile (e.g. for GUI editors)

Where it is not possible to use the --with-profile flag or the CHEMACS_PROFILE environment variable, the default profile can be set using a ~/.emacs-profile file.

If your ~/.emacs-profiles.el file contains the following:

(("default" . ((user-emacs-directory . "~/.emacs.default")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs")))
 ("prelude" . ((user-emacs-directory . "~/prelude"))))

you can create a file called ~/.emacs-profile, containing the name of the profile you’d like to be used when none is given on the command line:

$ echo 'spacemacs' > ~/.emacs-profile

This will set the default profile to be the “spacemacs” profile, instead of “default”. You can change the default by simply changing the contents of this file:

$ echo 'prelude' > ~/.emacs-profile

If this file doesn’t exist, then “default” will be used, as before.

Spacemacs

Spacemacs is typically installed by cloning the Spacemacs repo to ~/.emacs.d, and doing extra customization from ~/.spacemacs or ~/.spacemacs.d/init.el. This makes it tedious to switch between version of Spacemacs, or between different Spacemacs configurations.

With Chemacs you can point your user-emacs-directory to wherever you have Spacemacs installed, and use the SPACEMACSDIR environment variable to point at a directory with customizations that are applied on top of the base install.

(("spacemacs" . ((user-emacs-directory . "~/spacemacs")
                 (env . (("SPACEMACSDIR" . "~/.spacemacs.d")))))

 ("spacemacs-develop" . ((user-emacs-directory . "~/spacemacs/develop")
                        (env . (("SPACEMACSDIR" . "~/.spacemacs.d")))))

 ("new-config" . ((user-emacs-directory . "~/spacemacs/develop")
                  (env . (("SPACEMACSDIR" . "~/my-spacemacs-config"))))))

DOOM emacs

You can add an entry similar to the following to your .emacs-profiles.el

In the following snippet ~/doom-emacs is where you have cloned doom emacs.

(Depending on when you read this) DOOMDIR support is only in develop branch of doom emacs. Check commit history of master branch of doom emacs

("doom" . ((user-emacs-directory . "~/doom-emacs")
           (env . (("DOOMDIR" . "~/doom-config")))))

Please refer to this discussion for details.

FreeDesktop Directories

Both ~/.emacs-profiles.el and ~/.emacs-profile can also be stored under $XDG_CONFIG_HOME/chemacs (typically ~/.config/chemacs) as $XGD_CONFIG_HOME/chemacs/profiles.el and $XDG_CONFIG_HOME/chemacs/profile respectively.

Further, as indicated by the Emacs 27.1 changelog, Emacs is now compatible with XDG Standards, looking for its configuration files in ${XDG_CONFIG_HOME}/emacs directory too (provided the traditional ~/.emacs.d and ~/.emacs does not exist). Therefore, it is perfectly viable to install Chemacs 2 in ${XDG_CONFIG_HOME}/emacs (usually ~/.config/emacs) directory - with the aforementioned caveat: the directory =~/.emacs.d”= and the file =”~/.emacs”= does not exist.

Example: emacs as daemon

  • Profiles

You can add an entry similar to the following to your .emacs-profiles.el

;; your custom or vanilla emacs profile
(("default" . ((user-emacs-directory . "~/.gnu-emacs")
	       (server-name . "gnu")
	       ))

;; emacs distribution: DOOM-emacs
("doom" . ((user-emacs-directory . "~/.doom-emacs")
	   (server-name . "doom")
	   (env . (("DOOMDIR" . "~/.doom.d")))
	     ))
  )
  • daemon

Set emacs daemon to always run in background

# vanilla
emacs --daemon &
# Doom emacs
emacs --with-profile doom --daemon &
  • emacsclient

create a new frame, connect to the socket and use vanilla emacs as fallback

emacsclient -c -s gnu -a emacs
emacsclient -c -s doom -a emacs

Troubleshooting

Emacs cannot find packages installed by straight

Some users have reported issues where packages installed by `straight.el` can no longer be found after switching to using `chemacs`.

First, make sure you haven’t hardcoded filepaths to “emacs.d” in your configuration. You should reference files inside a profile-specific emacs folder like this:

(setq some-var (expand-file-name "path/to/file" user-emacs-directory))

Second, if the issue persists you should delete the `build` folder in your `straight` directory and rebuild your dependencies.

If the issue persists please comment on the issue, because we are still trying to figure out the exact source of this problem, but this has solved the problem for some users.

LICENSE

Copyright © Arne Brasseur and contributors, 2018-2022

Distributed under the terms of the GPL v3.

chemacs2's People

Contributors

aisipos avatar andersontorres avatar artlogic avatar dadair-ca avatar dnbz avatar emacs18 avatar garrison avatar hewame avatar idmyn avatar jfhbrook avatar jsmestad avatar kidd avatar lazyatom avatar league avatar mandarvaze avatar pdbrown avatar plexus avatar porras avatar shervinsafavi avatar sobafuchs avatar xervon avatar yumasi avatar zardoz03 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chemacs2's Issues

Straight package integration with `straight-p` and some suggested enhancemment options.

I noticed the following description of the straight-p option here:

straight-p Enable the Straight functional package manager.

But I still don't know how to use this option in the configuration file, i.e., ~/.emacs-profiles.el. OTOH, I noticed the function definition corresponding to the configuration option of straight-p. I suggest change this function into the following for adding the use-package integration:

(defun chemacs-load-straight ()
  (defvar bootstrap-version)
  (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
        (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)
      (with-current-buffer
          (url-retrieve-synchronously
           "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
           'silent 'inhibit-cookies)
        (goto-char (point-max))
        (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))
   (straight-use-package 'use-package)
(setq straight-use-package-by-default t))

Regards,
HY

Allow chemacs-profiles from chemacs-profile to be globally available?

Note: I'm sending this patch as an issue only because I do not want to accidentally send a broken/odd PR to upstream, as I have other edits locally I don't want to commit. I apologize in advance for being awkward in this manner.

@@ -102,19 +101,20 @@
           (env-profile-value env-profile-value)
           (t chemacs-default-profile-name))))
 
+(defvar chemacs-profiles
+  (with-temp-buffer
+    (insert-file-contents chemacs-profiles-path)
+    (goto-char (point-min))
+    (condition-case err
+        (read (current-buffer))
+      (error
+       (error "Failed to parse %s: %s" chemacs-profiles-path (error-message-string err))))))
+
 (defvar chemacs-profile
   (if (and chemacs--with-profile-value
            (listp chemacs--with-profile-value))
       chemacs--with-profile-value
-    (let ((profiles
-           (with-temp-buffer
-             (insert-file-contents chemacs-profiles-path)
-             (goto-char (point-min))
-             (condition-case err
-                 (read (current-buffer))
-               (error
-                (error "Failed to parse %s: %s" chemacs-profiles-path (error-message-string err)))))))
-      (cdr (assoc chemacs-profile-name profiles)))))
+      (cdr (assoc chemacs-profile-name chemacs-profiles))))
 
 (unless chemacs-profile
   (error "No profile `%s' in %s" chemacs-profile-name chemacs-profiles-path))

Primarily the motivation for this is allowing for the user to program with the data that is read in here at EMACS' boot.
For example one could (albeit naively) use completing-read to provide arguments to restart-emacs (per issue #40) in order to change a chemacs install, without having to re-read from the chemacs-profiles-path.

(defun restart-emacs-with-other-profile (&optional profile)
   (interactive)
   (if (or (null profile) (called-interactively-p 'any))
       (restart-emacs (list "--with-profile" (completing-read "chemacs install to reboot into: "
                                                              (mapcar #'car chemacs-profiles)
                                                              nil t)))
     (and (stringp profile)
          (memq profile chemacs-profiles)
          (restart-emacs (list "--with-profile" profile)))))

Fails to start emacs with native comp

Am running doom and spacemacs configs using emacs 28.1 with native compilation.

Running either of these by symlinking .emacs.d to the relevant config directory is successful. However, replacing .emacs.d with an install of chemacs2 results in neither configs starting successfully.

A common theme in the warnings is reference to gv-setter. Contents of the warnings buffer from both doom and spacemacs are attached.

warnings-doom.txt
warnings-spacemacs.txt

Bug when user has not early-init.el

chemacs.el contains:

(if (and (boundp 'chemacs-early-init) chemacs-early-init)
    (when (file-exists-p early-init-file)
      (load early-init-file)
      (setq chemacs-early-init nil))
  ...)

This does not set chemacs-early-init to nil when the user has no early init file.

Passing straight-p through .emacs-profiles.el

I want to use straight.el as the package manager for my "default" profile and with that intention in .emacs-profiles.el I pass straight-p as shown below.

;; .emacs-profiles.el
(("doom"   . ((user-emacs-directory . "~/doom-emacs")))
 ("default" . ((user-emacs-directory . "~/.emacs.default")
	           (straight-p . t))))

Emacs hangs for quite some time and then launches with this error:

Warning (initialization): An error occurred while loading ‘/home/milton/.emacs.d/init.el’:
File error: Failed connect, Connection timed out

Is my syntax for straight-p correct?

Can't resolve path in ~/.config/chemacs/profiles.el

Can't resolve environment variables in profiles.el

In ${XDG_CONFIG_HOME}/chemacs/profiles.el

  • The uncommented code works
  • Commented code throws the error:
Wrong type argument: stringp, (concatenate 'string (or (getenv XDG_DATA_HOME) (concat (getenv HOME) .local/share)) /profiles/spacemacs
;; (("default" . ((user-emacs-directory . (concatenate 'string
;;                                          (or
;;                                            (getenv "XDG_DATA_HOME")
;;                                            "~/.local/share")
;;                                          "/profiles/spacemacs"))))
;; ("doom" .     ((user-emacs-directory . (concatenate 'string
;;                                          (or
;;                                            (getenv "XDG_DATA_HOME")
;;                                            "~/.local/share")
;;                                          "/profiles/doom-emacs")))))



(("default" . ((user-emacs-directory . "~/.local/share/profiles/spacemacs")))
("doom" .     ((user-emacs-directory . "~/.local/share/profiles/doom-emacs"))))
  • Problem-Case: ${XDG_DATA_HOME} is set to a non-default location and I want to sync my chemacs configuration

Error after upgrading

Hi, I just updated&compiled to the last master of emacs, and upon restarting I got:

Warning (initialization): An error occurred while loading ‘/home/my/.emacs.d/init.el’:

Symbol's value as variable is void: \213

I've checked init.el and there's nothing weird. My .emacs-profiles.el is:

(("spacemacs" . ((user-emacs-directory . "~/.spacemacs.d")))
 ("my-emacs" . ((user-emacs-directory . "~/.my-emacs.d"))))

Any help will be much appreciated.

Minimum Emacs version?

Thanks for making Chemacs2!

My current version of Emacs is 27.2 and as it does provide for the use of early-init.el I assumed that Chemacs2 would work with it.

But as hard as I tried, I wasn't able to make the --with-profile option work, or get emacs to pickup the right profile without specifying 'default' (either in .emacs-profile.el or within .emacs-profile):

$ cat ~/.emacs-profiles.el
(("legacy" . ((user-emacs-directory . "~/.config/emacs/.legacy")))
 ("current" . ((user-emacs-directory . "~/.config/emacs/.legacy")))
 ("rational" . ((user-emacs-directory . "~/.rational-emacs"))))

$ cat ~/.emacs-profile
cat: .emacs-profile: No such file or directory

$ emacs --with-profile legacy

The above results in error: No profile ‘default’ in ~/.emacs-profiles.el within the emacs start-up screen

However when either specifying 'default' within .emacs-profiles.el or e.g. 'legacy' within .emacs-profiles, emacs always picks the default/legacy screen as per above, no matter what --with-profile specifies:

$ echo 'legacy' > ~/.emacs-profile
 $ emacs --with-profile rational

(results in emacs legacy profile instead of rational)

So the only way to make Emacs 27.2 choose the right version is by hard-coding the chosen profile within .emacs-profile
before each start-up, which is not definitely not as fluid as intended by Chemacs2 :)

However, after compiling and trying out emacs 29.0.50, Chemacs2 works great and as intended.

I assume I should install Emacs 28 - can anyone confirm a Minimum version before I do?
Thanks!

Default profile in XDG_CONFIG_HOME

In chemacs.el:

(defvar chemacs-default-profile-paths (list "~/.emacs-profile" (format "%s/%s" config-home "profile")))

It probably should be "chemacs/profile" instead of "profile".

errors when emacs is launched without explicitly providing any profile name

Here are the required files

$ cat ~/.emacs-profile
'emacs'
$ cat ~/.emacs-profiles.el 
(("emacs" . ((user-emacs-directory . "~/emacs/emacs.d")))
 ("doom"  . ((user-emacs-directory . "~/emacs/doom.d/")
            (env . (("DOOMDIR" . "~/kadal/aalar/emacs/doom.d"))))))
$ 
Debugger entered--Lisp error: (wrong-type-argument symbolp (quote emacs))
  symbol-name((quote emacs))
  (progn (insert-file-contents chemacs-default-profile-path) (goto-char (point-min)) (symbol-name (read (current-buffer))))
  (unwind-protect (progn (insert-file-contents chemacs-default-profile-path) (goto-char (point-min)) (symbol-name (read (current-buffer)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents chemacs-default-profile-path) (goto-char (point-min)) (symbol-name (read (current-buffer)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents chemacs-default-profile-path) (goto-char (point-min)) (symbol-name (read (current-buffer)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  (if (file-exists-p chemacs-default-profile-path) (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert-file-contents chemacs-default-profile-path) (goto-char (point-min)) (symbol-name (read (current-buffer)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) "default")
  chemacs-detect-default-profile()
  (chemacs-load-profile (chemacs-detect-default-profile))
  (if args (let ((s (split-string (car args) "="))) (cond ((equal (car args) "--with-profile") (add-to-list (quote command-switch-alist) (quote ("--with-profile" lambda (_) (pop command-line-args-left)))) (chemacs-load-profile (car (cdr args)))) ((equal (car s) "--with-profile") (add-to-list (quote command-switch-alist) (cons (car args) (quote (lambda ...)))) (chemacs-load-profile (mapconcat (quote identity) (cdr s) "="))) (t (chemacs-check-command-line-args (cdr args))))) (chemacs-load-profile (chemacs-detect-default-profile)))
  chemacs-check-command-line-args(nil)
  (cond ((equal (car args) "--with-profile") (add-to-list (quote command-switch-alist) (quote ("--with-profile" lambda (_) (pop command-line-args-left)))) (chemacs-load-profile (car (cdr args)))) ((equal (car s) "--with-profile") (add-to-list (quote command-switch-alist) (cons (car args) (quote (lambda (_))))) (chemacs-load-profile (mapconcat (quote identity) (cdr s) "="))) (t (chemacs-check-command-line-args (cdr args))))
  (let ((s (split-string (car args) "="))) (cond ((equal (car args) "--with-profile") (add-to-list (quote command-switch-alist) (quote ("--with-profile" lambda (_) (pop command-line-args-left)))) (chemacs-load-profile (car (cdr args)))) ((equal (car s) "--with-profile") (add-to-list (quote command-switch-alist) (cons (car args) (quote (lambda (_))))) (chemacs-load-profile (mapconcat (quote identity) (cdr s) "="))) (t (chemacs-check-command-line-args (cdr args)))))
  (if args (let ((s (split-string (car args) "="))) (cond ((equal (car args) "--with-profile") (add-to-list (quote command-switch-alist) (quote ("--with-profile" lambda (_) (pop command-line-args-left)))) (chemacs-load-profile (car (cdr args)))) ((equal (car s) "--with-profile") (add-to-list (quote command-switch-alist) (cons (car args) (quote (lambda ...)))) (chemacs-load-profile (mapconcat (quote identity) (cdr s) "="))) (t (chemacs-check-command-line-args (cdr args))))) (chemacs-load-profile (chemacs-detect-default-profile)))
  chemacs-check-command-line-args(("emacs"))
  eval-buffer(#<buffer  *load*-385706> nil "/home/vanangamudi/.emacs.d/chemacs.el" nil t)  ; Reading at buffer position 6257
  load-with-code-conversion("/home/vanangamudi/.emacs.d/chemacs.el" "/home/vanangamudi/.emacs.d/chemacs.el" nil nil)
  load("/home/vanangamudi/.emacs.d/chemacs.el")
  (let ((chemacs-directory (file-name-directory (file-truename load-file-name)))) (load (expand-file-name "chemacs.el" chemacs-directory)))
  eval-buffer(#<buffer  *load*> nil "/home/vanangamudi/.emacs.d/init.el" nil t)  ; Reading at buffer position 193
  load-with-code-conversion("/home/vanangamudi/.emacs.d/init.el" "/home/vanangamudi/.emacs.d/init.el" t t)
  load("/home/vanangamudi/.emacs.d/init" t t)
  #f(compiled-function () #<bytecode 0x1e0f4d>)()
  command-line()
  normal-top-level()

cannot load my doom on macos

msg:

No such file or directory, core-modules

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

debug backtrack

  Debugger entered--Lisp error: (file-missing "Cannot open load file" "No such file or directory" "/Users/$
  (doom-debug-mode 1)
  (if doom-debug-p (doom-debug-mode 1))
  (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))$
  (if (or force-p (not doom-init-p)) (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-$
  doom-initialize()
  eval-buffer(#<buffer  *load*-568364> nil "/Users/six/.emacs.d.doom/init.el" nil t)  ; Reading at buffe$
  load-with-code-conversion("/Users/six/.emacs.d.doom/init.el" "/Users/six/.emacs.d.doom/init.el" t t)
  load("/Users/six/.emacs.d.doom/init.el" t t)
  (let ((init-file (expand-file-name "init.el" user-emacs-directory))) (setq package-user-dir (expand-fi$
  chemacs-load-user-init()
eval-buffer(#<buffer  *load*> nil "/Users/six/.emacs.d/init.el" nil t)  ; Reading at buffer position 2$
  load-with-code-conversion("/Users/six/.emacs.d/init.el" "/Users/six/.emacs.d/init.el" t t)
  load("/Users/six/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1fe98f66a329>) #f(compiled-function $
  command-line()
  normal-top-level() 

and my .emacs-profiles.el:

(("default" . ((user-emacs-directory . "~/.emacs.d.doom")
	       (env . (("DOOMDIR" . "~/.doom.d"))))))

emacs version is 27.1

Windows support

Hi, does chemacs2 support windows ?
Recently, I used chemacs2 on windows, but failed.

connect-the-dots referenced but undocumented

I'm currently using stow. Is connect-the-dots better for me? I can't know, really, because I can't guess what it really does. Suggest writing a little doc, or removing the reference.

Feature request: associate profiles with Emacs executables and get Chemacs 2 to launch with those instead.

As there is usually just one emacs executable on the path and different profiles may need different versions of Emacs, I suggest that Chemacs profiles have Emacs executables associated with them, ie an EMACS variable that points the emacs executable to use.

So for instance if you have all six of Emacs 24 - 29 in addition to various task specific or test builds running on your system for whatever reason, having each profile associated with a particular executable means you don't have to worry about using the right version of Emacs to run a particular profile.

Together with Emacs 29 new capability of allowing the .emacs.d to be passed on the command line, this will provide a capability that Emacs and particularly Emacs lisp has lacked for a long time.

That way you could have something like this:

("doom" . ((user-emacs-directory . "~/doom-emacs")
                (env . (("EMACS" . "~/opt/emacs-28.2-test-build/bin/emacs")))
               (env . (("DOOMDIR" . "~/doom-config")))
))

If on launching Chemacs 2 detects that the Emacs executable it started with is not the one in the EMACS variable for that profile it launches that profile again with the associated executable

Command line arguments "leak"

Hi! I'm not sure if this is an issue of chemacs2 or emacs-dashboard (the package I'm having trouble with), but I decided to post it here thinking that you all will be more familiar with the nuances of command line arguments 😬 If you think this is a problem of emacs-dashboard, I'll submit it there.

When I run emacs --profile whatever, chemacs2 does its thing (and does it well), but the command line arguments stay there in the command-line-args variable, as C-h v shows:

command-line-args is a variable defined in ‘C source code’.

Its value is ("emacs" "--with-profile" "whatever")

emacs-dashboard uses (< (length command-line-args) 2) to check if emacs was called to open a file. This check obviously yields the wrong result here. But I'm not sure who's at fault here (and how should it be fixed)

  • Should chemacs remove those args from the list here? (happy to give an attempt to a PR if you think this is the case). I think this is the case, because that's what happens with the other normal options that get passed to emacs from the command line (I tried --maximize and -Q, they do their thing but they don't show up in command-line-args)
  • Or should emacs-dashboard use command-line-args-left instead? Or something else? (happy to report or PR there if you think that's the case)

weired issue with flycheck enabled

If I enable flycheck-mode, cache files will be saved to chemacs dir. here is an example init, with (setq native-comp-eln-load-path (list (concat user-emacs-directory "var/eln-cache/"))) in my early-init.el

(setq package-archives '(("melpa"        . "https://melpa.org/packages/")
                         ("melpa-stable" . "https://stable.melpa.org/packages/")
                         ("org"          . "https://orgmode.org/elpa/")
                         ("gnu"          . "https://elpa.gnu.org/packages/"))
      package-user-dir (concat user-emacs-directory "elpa/"
                               (format "%d%s%d"
                                       emacs-major-version
                                       version-separator
                                       emacs-minor-version)))

;; initialize packages
(unless (bound-and-true-p package--initialized) ; To avoid warnings in 27
  (setq package-enable-at-startup nil)          ; To prevent initializing twice
  (package-initialize))

;; setup `use-package'
(unless (package-installed-p 'use-package)
  (when (not package-archive-contents)
    (package-refresh-contents))
  (package-install 'use-package))

(require 'use-package)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(use-package no-littering :ensure t :defer t)

; (use-package flycheck
;   :ensure t
;   :hook (prog-mode . flycheck-mode))

GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.5.0, NS appkit-2022.50 Version 11.4 (Build 20F71)) of 2021-06-21

Screen Shot 2021-07-01 at 14 49 47

`etc` `var` and `eln-cache` was not generated in chemacs dir(`~/.emacs.d/`) without flycheck enable.

Directory entries aren't expanded when passed to a shell?

The entry for a DOOMDIR in my ~/.emacs-profiles.el is DOOMDIR is ("DOOMDIR" . "~/Data/Emacs/doom_dirs/01.doom.01").

I notice that when I start a terminal eg vterm it is passed as a quoted string so ls $DOOMDIR results in a directory not found error.

In the shell setting DOOMDIR=~/Data/Emacs/doom_dirs/01.doom.01 results in ls $DOOMDIR giving the expected result but DOOMDIR="~/Data/Emacs/doom_dirs/01.doom.01" or DOOMDIR='~/Data/Emacs/doom_dirs/01.doom.01' i.e. quoting the value means it is not expanded, and so ls takes the literal quoted string.

I don't know where the fault is but it seems there should be away of passing the values to the shell in the expected manner. Chemacs2 is clearly passing on the value as entered in ~/.emacs-profiles.el.

Is this likely to be an Emacs thing and is there some workaround for this?

Flycheck error "user-emacs-directory . ~/.emacs.default))" is a malformed function

Hello,
I believe this error comes from flycheck expecting the first (unquoted) element in the sexp to be a function.

`(default (user-emacs-directory . ~/.emacs.default))' is a malformed function

GNU Emacs 29.0.50 (build 2, x86_64-w64-mingw32) of 2022-02-10
Windows 10 Pro

Not sure what is the best approach to dealing with it. Files load fine.

Thanks.
mp

Some problem with Spacemacs

Hi , thanks for your effort. Chemacs is a brilliant idea.

But after I add the env path in the ".emacs-profiles.el" for Spacemacs , I kept receiving such message "File is missing: Cannot open load file, No such file or directory, use-package"
Everything was fine with the "default" one and the spacemacs without ".spacemacs.d".
Could you pls help me out?
Thanks in advance.

daemon startup errors

Hi, I am trying to run a daemon/client(s) setup. When I use chemacs2, I get the following error:

Error loading autoloads: (invalid-read-syntax )

I have confirmed that it does not depend on the specific config I am loading (by using an empty init.el). Is anyone else also experiencing this? I think the errors are harmless, but still, if there's a way to not have them I'd like to try!

Cheers

possible advice for straight.el users?

Apologies for not having enough time to make a proper report. I've used Chemacs in the past successfully and wanted to try rolling up a new config today after spending over a year with one I've been chipping away at. So I installed Chemacs 2 and tried restarting, only to get a few issues with my straight.el + org based config.

I began running into what appeared to be path issues. all-the-icons failed to find ./data/something-or-other and then straight could not seem to even find git to execute properly.

It smelled of issues with the byte-compiled files, so i just razed the build directory for the straight packages and restarted which had straight rebuild / recompile everything.

Now it appears to work fine, but perhaps this may be useful to notate in the readme for users adopting an existing config. it may be unrelated to straight, and simply something about byte compiled files and paths getting moved that i'm unaware of.

thanks for the work on chemacs btw! its been quite handy in a few different scenarios over the years.

Questions about setting a default profile, ~/.emacs.default and symlinks

If my .emacs-profiles.el contents are:

(("centaur" . ((user-emacs-directory . "~/.emacs-profiles.d/centaur-emacs")))
 ("default" . ((user-emacs-direcotry . "~/.emacs.default")))
 ("emacs" . ((user-emacs-directory . "~/.emacs-profiles.d/emacs")))
 ("doom" . ((user-emacs-directory . "~/.emacs-profiles.d/doom-emacs")))
 ("lsp" . ((user-emacs-directory . "~/.emacs-profiles.d/lsp")))
 ("purcell" . ((user-emacs-directory . "~/.emacs-profiles.d/purcell-emacs")))
 ("prelude" . ((user-emacs-directory . "~/.emacs-profiles.d/prelude-emacs")))
 ("scimax" . ((user-emacs-directory . "~/.emacs-profiles.d/scimax")))
 ("spacemacs" . ((user-emacs-directory . "~/.emacs-profiles.d/spacemacs")
                 (env . (("SPACEMACSDIR" . "~/.spacemacs.d"))))))

and my .emacs-profile contents are:

spacemacs
  1. Do I really need to include a "default" entry in .emacs-profiles?
  2. If so, does the associated value must always be "~/.emacs.default"?
  3. If so, can "~/.emacs.default" be a symlink pointing to "~/.emacs-profiles.d/spacemacs"?

Init cannot be loaded from directory.

Am trying to setup chemacs with doom and my own config.
When trying to load my default config, emacs tells me it cannot find the directory where my config.org file is located.
This config.org file is pointed at in my init.el like so:
(org-babel-load-file "~/.emacs.d/ae/config.org")
Obviously that path is not valid with chemacs.
How can I tell emacs the current directory without going through my config and changing everything into hard coded paths? (Yes, am rather new to emacs.)

When trying to load doom, I get something similar:
It cannot find the core-modules directory.

This is my chemacs .emacs-profiles.el file:

 (("default"   . ((user-emacs-directory . "~/.emacs.d-ae")))
  ("legacy" . ((user-emacs-directory . "~/.emacs.d-legacy")))
  ("doom"   . ((user-emacs-directory . "~/.emacs.d-doom")))
  ("scimacs" . ((user-emacs-directory . "~/.emacs.d-scimacs"))))

User init files loaded more than once

At the end chemacs.el does:

(chemacs-check-command-line-args command-line-args)

However, that is done in early-init.el and in init.el as well. The effect is that the user init file gets loaded several times.

emacs 27 and 29 from chemacs2: is it possible?

Hi there,

I have Kubuntu Linux 22.04 (Jammy Jellyfish) as operating system for my desktop. Its default stock (.deb) Emacs is version 27.1 and I have it working seamlessly (via emacs --with-profile ) for the several Chemacs2 profiles I configured in ~/.emacs-profiles.el; those are:
(i) the default (my-emacs) profile
(ii) the prelude profile
(ii) the doom profile.
The corresponding trees are under ~/.emacs-distros/

(It seems) I have now been able to build and install Emacs 29.0 from source and I chose to install it under /.emacs-distros/gnu-emacs and I have created a symlink called gnu-emacs to its executable (/.emacs-distros/gnu-emacs/bin/emacs). I added a new line, in ~/.eamcs-profiles.el, for this new "distro"/version. When I now issue:

gnu-emacs --with-profile gnu-emacs

it launches Emacs 29.0 without any errors or warnings. However, when I issue, for instnace:

gnu-emacs --with-profile my-emacs

Emacs 29.0 is launched, but with the following message:

⛔ Warning (initialization): An error occurred while loading ‘/home/orca/.emacs.d/early-init.el’:

error: No profile ‘my-emacs’ in ~/.emacs-profiles.el

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.
⛔ Warning (initialization): An error occurred while loading ‘/home/orca/.emacs.d/init.el’:

error: No profile ‘my-emacs’ in ~/.emacs-profiles.el

What does that mean? My ~/.emacs-profiles.el file reads:

(("default" . ((user-emacs-directory . "~/.emacs-distros/my-emacs")))
 ("prelude" . ((user-emacs-directory . "~/.emacs-distros/prelude-emacs")))
 ("gnu-emacs" . ((user-emacs-directory . "~/.emacs-distros/gnu-emacs")))
 ("doom"    . ((user-emacs-directory . "~/.emacs-distros/doom-emacs")))
 ("scimax"  . ((user-emacs-directory . "~/.emacs-distros/scimax"))))

Shouldn´t this last command work seamlessly, as does the one: emacs --with-profile my-emacs? I would like to still keep trying/experimenting with the several "distros" with the new version of emacs...

Obsolete comment in chemacs.el

The comment

;; this must be here to keep the package system happy, normally you do
;; `package-initialize' for real in your own init.el
;; (package-initialize)

in chemacs.el is obsolete with Emacs 27. Even if it were not, then it would have to be in init.el.

By the way, is Chemacs2 intended to support older Emacs'en, too? Or only Emacs 27 upwards?

`restart-emacs` results in the default configuration loading

I apologize in advance if this is in rtfm territory, but it appears that if I load a non default profile via chemacs, like for example
emacs --with-profile not-defualt-profile
and I attempt to restart emacs with restart-emacs, it loads the default configuration instead of the configuration initially specified.
This might be intended behavior but I couldn't find anything with a quick look through issues; I apologize if this is redundant or intended behavior.

Why special support for straight?

What is the rationale for straight-p and chemacs-load-straight? Why isn't this something that the user should handle in his (early) init? Why not every other package manger (Borg, ...), too?

chemacs-load-straight may try to download a file if it is not yet there. That is highly opinionated.

There must be a very strong reason for supporting it in Chemacs and that should be documented (at least in the source).

How to deal with references to ~/emacs.d?

After following the installation instructions and running emacs on the command line, I get the error

File is missing: Opening directory, No such file or directory, /home/tardigradis/.emacs.d/lisp

This is because I have

(let ((default-directory  "~/.emacs.d/lisp/"))
  (normal-top-level-add-subdirs-to-load-path))

in my init.el. How should such references be dealt with?

Spacemacs does not load its configuration file outside my home directory

I was trying to use Chemacs 2 for having different Spacemacs configurations, so I cloned this repo and created an .emacs-profiles.el that looks like this:

(("default" . ((user-emacs-directory . "~/.emacs.my.configs/spacemacs/master/.spacemacs.d")))
              (env . (("SPACEMACSDIR" . "~/.emacs.my.configs/spacemacs/master/.spacemacs.conf"))))

The directory .spacemacs.d contains the Spacemacs installation and the directory .spacemacs.conf contains the .spacemacs configuration file and the .spacemacs.env file, but when I start Emacs, it loads Spacemacs correctly but not the configuration. If I keep the .spacemacs file in my home directory it works fine. Maybe I'm doing something wrong?

package-user-dir stays at ~/.emacs.d/elpa

Recently there's been a change in emacs master branch, 9973019764250ac1f4d77a6b426cdd9c241151c5 ( emacs-mirror/emacs@9973019) where package-user-dir is loaded differently, making it bypass chemacs' directory linking.

c-h v package-user-dir before that commit gives ~/.emacs.default/elpa, but after it, you get ~/.emacs.d/elpa.

I'm still not 100% sure about the proper fix, but as of now this seems to fix it:

modified   chemacs.el
@@ -142,6 +142,7 @@
 (defun chemacs-load-user-init ()
   (when (chemacs-profile-get 'straight-p) (chemacs-load-straight))
   (let ((init-file (expand-file-name "init.el" user-emacs-directory)))
+    (setq package-user-dir (expand-file-name "elpa" user-emacs-directory))
     (load init-file t t)
     ;; Prevent customize from changing ~/.emacs (this file), but if
     ;; init.el has set a value for custom-file then don't touch it.

leaving it as an issue to give it some time

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.