iqbalansari / restart-emacs

A simple emacs package to restart emacs from within emacs
GNU General Public License v3.0
158 stars 15 forks source link

Doesn't work with Nix #24

Open nosewings opened 2 years ago

nosewings commented 2 years ago

When running an Emacs built with emacsWithPackages from Nix, restart-emacs picks the wrong Emacs binary to start.

emacsWithPackages creates a wrapper script that sets up the Emacs load path before running the Emacs binary. So what ends up happening is that restart-emacs executes the Emacs binary (obtained via invocation-directory), but without the load-path set properly.

The easiest solution I can see would be to allow the user to configure the command used to start a new Emacs instance.

nosewings commented 2 years ago

For what it's worth, I was able to get this working with something like the following:

(defun nosewings/restart-emacs-advice (function &rest args)
  (let ((invocation-directory "~/.nix-profile/bin/"))
    (apply function args)))
(advice-add #'restart-emacs :around #'nosewings/restart-emacs-advice)

However, this relies on the implementation detail that restart-emacs uses invocation-directory.