From e816a1ecaca8fdb0e058532985d3f51831c3d389 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 9 Jul 2018 23:34:37 +0200 Subject: [PATCH] Load exec-path-from-shell in daemon sessions On MacOS, the daemon is unlikely to run with the correct environment if launched through launchctl or brew services, so it makes sense to use exec-path-from-shell there too. May address #736 --- core/core-os.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/core-os.el b/core/core-os.el index 623da3bd0..32ed7124a 100644 --- a/core/core-os.el +++ b/core/core-os.el @@ -35,11 +35,11 @@ ;; Don't open files from the workspace in a new frame ns-pop-up-frames nil) - (if (not (display-graphic-p)) - (add-hook 'doom-post-init-hook #'osx-clipboard-mode) - ;; A known problem with GUI Emacs on MacOS: it runs in an isolated - ;; environment, so envvars will be wrong. That includes the PATH Emacs - ;; picks up. `exec-path-from-shell' fixes this. + (when (or (daemonp) (display-graphic-p)) + ;; A known problem with GUI Emacs on MacOS (or daemons started via + ;; launchctl or brew services): it runs in an isolated + ;; environment, so envvars will be wrong. That includes the PATH + ;; Emacs picks up. `exec-path-from-shell' fixes this. (when (require 'exec-path-from-shell nil t) (defun set-env! (&rest vars) "Inject VARS from your shell environment into Emacs." @@ -47,7 +47,11 @@ (setq exec-path-from-shell-check-startup-files nil exec-path-from-shell-arguments (delete "-i" exec-path-from-shell-arguments) exec-path-from-shell-debug doom-debug-mode) - (exec-path-from-shell-initialize)))) + (exec-path-from-shell-initialize))) + + ;; Fix the clipboard in terminal or daemon Emacs (non-GUI) + (when (or (daemonp) (not (display-graphic-p))) + (add-hook 'doom-post-init-hook #'osx-clipboard-mode))) (IS-LINUX (setq x-gtk-use-system-tooltips nil ; native tooltips are ugly!