[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: setenv documentation in elisp manual outdated
From: |
Richard Stallman |
Subject: |
Re: setenv documentation in elisp manual outdated |
Date: |
Wed, 12 Apr 2006 17:46:44 -0400 |
Actually, I wanted to look into the elisp manual because from the
doc string of setenv it was not clear to me what the difference was
between a nil value of VALUE and a value of t for UNSET. When does
one need the optional arg UNSET because nil for VALUE is not doing
the job?
Does this make things clearer? Does it work right?
*** env.el 07 Feb 2006 18:16:10 -0500 1.35
--- env.el 12 Apr 2006 15:18:29 -0400
***************
*** 90,117 ****
;; Fixme: Should `process-environment' be recoded if LC_CTYPE &c is set?
! (defun setenv (variable &optional value unset substitute-env-vars)
"Set the value of the environment variable named VARIABLE to VALUE.
VARIABLE should be a string. VALUE is optional; if not provided or
! nil, the environment variable VARIABLE will be removed. UNSET
! if non-nil means to remove VARIABLE from the environment.
! SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment
! variables in VALUE with `substitute-env-vars', where see.
! Value is the new value if VARIABLE, or nil if removed from the
! environment.
Interactively, a prefix argument means to unset the variable.
Interactively, the current value (if any) of the variable
appears at the front of the history list when you type in the new value.
Interactively, always replace environment variables in the new value.
This function works by modifying `process-environment'.
As a special case, setting variable `TZ' calls `set-time-zone-rule' as
a side-effect."
(interactive
(if current-prefix-arg
! (list (read-envvar-name "Clear environment variable: " 'exact) nil t)
(let* ((var (read-envvar-name "Set environment variable: " nil))
(value (getenv var)))
(when value
--- 90,119 ----
;; Fixme: Should `process-environment' be recoded if LC_CTYPE &c is set?
! (defun setenv (variable &optional value substitute-env-vars)
"Set the value of the environment variable named VARIABLE to VALUE.
VARIABLE should be a string. VALUE is optional; if not provided or
! nil, the environment variable VARIABLE will be removed.
Interactively, a prefix argument means to unset the variable.
Interactively, the current value (if any) of the variable
appears at the front of the history list when you type in the new value.
Interactively, always replace environment variables in the new value.
+ SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment
+ variables in VALUE with `substitute-env-vars', which see.
+ This is normally used only for interactive calls.
+
+ The return value is the new value of VARIABLE, or nil if
+ it was removed from the environment.
+
This function works by modifying `process-environment'.
As a special case, setting variable `TZ' calls `set-time-zone-rule' as
a side-effect."
(interactive
(if current-prefix-arg
! (list (read-envvar-name "Clear environment variable: " 'exact) nil)
(let* ((var (read-envvar-name "Set environment variable: " nil))
(value (getenv var)))
(when value
***************
*** 121,127 ****
(read-from-minibuffer (format "Set %s to value: " var)
nil nil nil 'setenv-history
value)
- nil
t))))
(if (and (multibyte-string-p variable) locale-coding-system)
(let ((codings (find-coding-systems-string (concat variable value))))
--- 123,128 ----
***************
*** 129,138 ****
(memq (coding-system-base locale-coding-system) codings))
(error "Can't encode `%s=%s' with `locale-coding-system'"
variable (or value "")))))
! (if unset
! (setq value nil)
! (if substitute-env-vars
! (setq value (substitute-env-vars value))))
(if (multibyte-string-p variable)
(setq variable (encode-coding-string variable locale-coding-system)))
(if (and value (multibyte-string-p value))
--- 130,138 ----
(memq (coding-system-base locale-coding-system) codings))
(error "Can't encode `%s=%s' with `locale-coding-system'"
variable (or value "")))))
! (and value
! substitute-env-vars
! (setq value (substitute-env-vars value)))
(if (multibyte-string-p variable)
(setq variable (encode-coding-string variable locale-coding-system)))
(if (and value (multibyte-string-p value))