bug#81591: 31.0.91; getenv fallback to selected frame is inaccurately documented
"Aaron L. Zeng" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I noticed a discrepancy in the description of how `getenv' (with a nil
FRAME argument) behaves when a variable is not found in
process-environment but is found in the selected frame's environment
parameter. getenv's docstring says:
If optional parameter FRAME is non-nil, then it should be a
frame. This function will look up VARIABLE in its ‘environment’
parameter.
Otherwise, this function searches ‘process-environment’ for
VARIABLE. If it is not found there, then it continues the search
in the environment list of the selected frame.
So, when FRAME is nil, I would expect that any variables not present
in `process-environment' should be looked up in the selected frame's
environment. However, this does not happen for SSH_CONNECTION
(reading the source of getenv_internal, it seems to actually be a
special case for DISPLAY and no other variables). I noticed I had to
explicitly pass the selected frame to the `getenv' function.
Looking at the history of getenv_internal, it seems quite deliberate
that DISPLAY is a special case and that no other variables were
intended to be looked up in the selected frame implicitly. If that's
the case, I would suggest the docstring should be updated to mention
it.
Thanks,
Aaron
P.S. for context, I use X11 forwarding over SSH to access Emacs on a Linux
server from several different computers. I have have some Lisp code
which uses `getenv' to get the value of the SSH_CONNECTION environment
variable, and then use that information to open a new browser tab on
my SSH *client*, when I browse-url in Emacs.
In GNU Emacs 31.0.91 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.4, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101023
System Description: NixOS 26.05 (Yarara)
Configured using:
'configure
--prefix=/nix/store/dk9k4hva1cdlh03m9i82m80ckvnzzc3r-emacs-31.0.91
--disable-build-details --with-modules --with-x-toolkit=lucid
--with-cairo --without-xft --disable-gc-mark-trace
--with-compress-install --with-toolkit-scroll-bars
--with-native-compilation --without-imagemagick --with-mailutils
--without-small-ja-dic --with-tree-sitter --with-xinput2
--without-xwidgets --with-dbus --with-selinux'
Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM
XRANDR LUCID ZLIB
Important settings:
value of $EMACSLOADPATH:
value of $EMACSNATIVELOADPATH:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix