aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2006-04-18 21:17:50 +0000
committerRichard M. Stallman2006-04-18 21:17:50 +0000
commit27bdc650c3f02f2d8669e367ef3c8683a5b630d3 (patch)
tree9478299c8d6aec7303c18978e0dbc92b8d8640a7
parent75669e022315b9480b979b795416a87b006bdeac (diff)
downloademacs-27bdc650c3f02f2d8669e367ef3c8683a5b630d3.tar.gz
emacs-27bdc650c3f02f2d8669e367ef3c8683a5b630d3.zip
(setenv): Get rid of arg UNSET. Interactive unsetting
now works by passing nil as arg.
-rw-r--r--lisp/env.el26
1 files changed, 13 insertions, 13 deletions
diff --git a/lisp/env.el b/lisp/env.el
index 81760ececfc..1b6c038cbea 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -90,28 +90,30 @@ Use `$$' to insert a single dollar sign."
90 90
91;; Fixme: Should `process-environment' be recoded if LC_CTYPE &c is set? 91;; Fixme: Should `process-environment' be recoded if LC_CTYPE &c is set?
92 92
93(defun setenv (variable &optional value unset substitute-env-vars) 93(defun setenv (variable &optional value substitute-env-vars)
94 "Set the value of the environment variable named VARIABLE to VALUE. 94 "Set the value of the environment variable named VARIABLE to VALUE.
95VARIABLE should be a string. VALUE is optional; if not provided or 95VARIABLE should be a string. VALUE is optional; if not provided or
96nil, the environment variable VARIABLE will be removed. UNSET 96nil, the environment variable VARIABLE will be removed.
97if non-nil means to remove VARIABLE from the environment.
98SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment
99variables in VALUE with `substitute-env-vars', where see.
100Value is the new value if VARIABLE, or nil if removed from the
101environment.
102 97
103Interactively, a prefix argument means to unset the variable. 98Interactively, a prefix argument means to unset the variable.
104Interactively, the current value (if any) of the variable 99Interactively, the current value (if any) of the variable
105appears at the front of the history list when you type in the new value. 100appears at the front of the history list when you type in the new value.
106Interactively, always replace environment variables in the new value. 101Interactively, always replace environment variables in the new value.
107 102
103SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment
104variables in VALUE with `substitute-env-vars', which see.
105This is normally used only for interactive calls.
106
107The return value is the new value of VARIABLE, or nil if
108it was removed from the environment.
109
108This function works by modifying `process-environment'. 110This function works by modifying `process-environment'.
109 111
110As a special case, setting variable `TZ' calls `set-time-zone-rule' as 112As a special case, setting variable `TZ' calls `set-time-zone-rule' as
111a side-effect." 113a side-effect."
112 (interactive 114 (interactive
113 (if current-prefix-arg 115 (if current-prefix-arg
114 (list (read-envvar-name "Clear environment variable: " 'exact) nil t) 116 (list (read-envvar-name "Clear environment variable: " 'exact) nil)
115 (let* ((var (read-envvar-name "Set environment variable: " nil)) 117 (let* ((var (read-envvar-name "Set environment variable: " nil))
116 (value (getenv var))) 118 (value (getenv var)))
117 (when value 119 (when value
@@ -121,7 +123,6 @@ a side-effect."
121 (read-from-minibuffer (format "Set %s to value: " var) 123 (read-from-minibuffer (format "Set %s to value: " var)
122 nil nil nil 'setenv-history 124 nil nil nil 'setenv-history
123 value) 125 value)
124 nil
125 t)))) 126 t))))
126 (if (and (multibyte-string-p variable) locale-coding-system) 127 (if (and (multibyte-string-p variable) locale-coding-system)
127 (let ((codings (find-coding-systems-string (concat variable value)))) 128 (let ((codings (find-coding-systems-string (concat variable value))))
@@ -129,10 +130,9 @@ a side-effect."
129 (memq (coding-system-base locale-coding-system) codings)) 130 (memq (coding-system-base locale-coding-system) codings))
130 (error "Can't encode `%s=%s' with `locale-coding-system'" 131 (error "Can't encode `%s=%s' with `locale-coding-system'"
131 variable (or value ""))))) 132 variable (or value "")))))
132 (if unset 133 (and value
133 (setq value nil) 134 substitute-env-vars
134 (if substitute-env-vars 135 (setq value (substitute-env-vars value)))
135 (setq value (substitute-env-vars value))))
136 (if (multibyte-string-p variable) 136 (if (multibyte-string-p variable)
137 (setq variable (encode-coding-string variable locale-coding-system))) 137 (setq variable (encode-coding-string variable locale-coding-system)))
138 (if (and value (multibyte-string-p value)) 138 (if (and value (multibyte-string-p value))