Closed pierre-rouleau closed 3 years ago
The last commit implements something very similar to what is described above. If you use macOS and Bash you do not need to define a PEL_SHELL
environment variable as it uses the _
environment variable as the detection mechanism. But for other environments you will have to identify the environment variable to use and there is a PEL user-option for that: pel-shell-detection-envvar
.
PEL fast-startup, terminal/graphics independent customization and package quickstart control depend on ability to detect the environment and for some of this logic that depends on Emacs being launched from a shell.
It's possible to launch Emacs from outside of a shell in several operating systems. When its done PEL code is not able to detect important information and several Emacs package are not initialized properly.
Steve Purcell provides a library to handle this but its solution increases the Emacs startup time (it launches a child shell and extracts the environment values out of that shell to add them to the ones used by future Emacs shell children).
One of PEL goals is to speed Emacs startup. Steve Purcell's library is therefore not a good fit for PEL.
On macOS it's possible to store extra environment variables inside the macOS Emacs app bundle Info.plist file. This however is not very flexible and also only works on macOS.
Compounding the problem is the fact that some decisions PEL must make have to be taken inside the execution of early-init.el which is before the customization file is loaded. For the moment only one environment-based decision must be taken by PEL inside early-init.el: to determine if Emacs is running in terminal or graphics mode.
PEL_RUNNING_IN_GRAPHICS
environment variable to indicate that Emacs is running in graphics mode. That's possible to do when the graphical instance of Emacs is launched from a shell. But if it's launched from a GUI application like Windows Explorer or macOS Finder, then other ways must be used. on macOS the value can be set inside the Info.plist file of the app bundle. on Windows: I'm not sure it can be done. ** on Linux, and other Unix OS graphical environments: also not sure if that can be done.One possible solution would be to find a environment variable that is always defined when Emacs was launched from a shell and that is also not defined when Emacs is launched from a GUI program like Windows Explorer or macOS Finder.
_
environment variable can be used for that. It is only set when Emacs was launched from Bash.PEL_SHELL
. This could also identify the shell type. ** IfPEL_SHELL
is not set we know Emacs is running in graphics mode.If
PEL_SHELL
is set we know Emacs was launched from a shell, we then use a second environment variable to distinguish terminal and graphics mode:PEL_RUNNING_IN_GRAPHICS
is set when graphics EMACS is launched.CURRENT PROPOSED SOLUTION:
PEL_SHELL
environment variable inside the shell, for instance inside the~/.bash_profile
when Bash is used. That is used to identify the presence of a shell. PEL code would be modified to expect that environment variable.** If
PEL_SHELL
environment variable is not present, PEL provides customization user-option variable to add or append values to the Emacs environment:pel-gui-process-environment
, a list of key-value pairs where the key is the environment variable name and the value is the string to set or append to a possibly existing environment variable. *** PEL would provide logic to inject the extra values defined bypel-gui-process-environment
into the environment (via functionsetenv
or variablesexec-path
andeshell-path-env
) whenPEL_SHELL
is not set.