[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PWD is not seen by my emacs installation
From: |
Rudolf Adamkovič |
Subject: |
Re: PWD is not seen by my emacs installation |
Date: |
Thu, 31 Aug 2023 00:29:40 +0200 |
Patrick Mahan <plmahan@gmail.com> writes:
> Hardware -
>
> Macbook Pro 14" (Apple M1 Pro)
> Mac OS 13.1 (Ventura)
I am on the same system, with the same
problem, and I solved it as follows...
>From my literate configuration file:
[...]
Copy the =$PATH=, =$MANPATH=, and =LC_ALL=
variables from the interactive login shell to
Emacs. This is necessary on macOS, as its
GUI starts programs within a minimal
environment.
In practice, this fixes various problems,
such as the =*compilation*= buffer not
finding =emacs=, =fortune= not finding
=strfile=, =geiser-mode= not finding =guile=,
=emacs= not finding =gcc= for native
compilation, as well as, spurious =locale=
warnings.
#+BEGIN_SRC emacs-lisp :eval no :tangle ~/.emacs
(when (eq window-system 'ns)
(defun shell-get-environment-variable+ (variable)
"Return the value of VARIABLE from login shell."
(shell-command-to-string
(format "$SHELL --login -c 'echo -n $%s'" variable)))
;;
;; Set the path variable.
(let* ((path "PATH")
(path-value (shell-get-environment-variable+ path)))
(setenv path path-value)
(setq exec-path (split-string path-value path-separator)))
;;
;; Set the locale.
(let* ((variable "LC_ALL")
(variable-value (shell-get-environment-variable+ variable)))
(setenv variable variable-value)))
#+END_SRC
P.S. 1: My code launches the login shell
twice instead of once, which is something to
improve.
P.S. 2: It would be useful to have a command
that does this in vanilla Emacs.
Rudy
--
"Programming reliably -- must be an activity
of an undeniably mathematical nature […] You
see, mathematics is about thinking, and doing
mathematics is always trying to think as well
as possible." -- Edsger W. Dijkstra, 1981
Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia
Re: PWD is not seen by my emacs installation,
Rudolf Adamkovič <=