diff options
| author | Richard M. Stallman | 2006-04-18 21:17:50 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-04-18 21:17:50 +0000 |
| commit | 27bdc650c3f02f2d8669e367ef3c8683a5b630d3 (patch) | |
| tree | 9478299c8d6aec7303c18978e0dbc92b8d8640a7 /lisp | |
| parent | 75669e022315b9480b979b795416a87b006bdeac (diff) | |
| download | emacs-27bdc650c3f02f2d8669e367ef3c8683a5b630d3.tar.gz emacs-27bdc650c3f02f2d8669e367ef3c8683a5b630d3.zip | |
(setenv): Get rid of arg UNSET. Interactive unsetting
now works by passing nil as arg.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/env.el | 26 |
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. |
| 95 | VARIABLE should be a string. VALUE is optional; if not provided or | 95 | VARIABLE should be a string. VALUE is optional; if not provided or |
| 96 | nil, the environment variable VARIABLE will be removed. UNSET | 96 | nil, the environment variable VARIABLE will be removed. |
| 97 | if non-nil means to remove VARIABLE from the environment. | ||
| 98 | SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment | ||
| 99 | variables in VALUE with `substitute-env-vars', where see. | ||
| 100 | Value is the new value if VARIABLE, or nil if removed from the | ||
| 101 | environment. | ||
| 102 | 97 | ||
| 103 | Interactively, a prefix argument means to unset the variable. | 98 | Interactively, a prefix argument means to unset the variable. |
| 104 | Interactively, the current value (if any) of the variable | 99 | Interactively, the current value (if any) of the variable |
| 105 | appears at the front of the history list when you type in the new value. | 100 | appears at the front of the history list when you type in the new value. |
| 106 | Interactively, always replace environment variables in the new value. | 101 | Interactively, always replace environment variables in the new value. |
| 107 | 102 | ||
| 103 | SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment | ||
| 104 | variables in VALUE with `substitute-env-vars', which see. | ||
| 105 | This is normally used only for interactive calls. | ||
| 106 | |||
| 107 | The return value is the new value of VARIABLE, or nil if | ||
| 108 | it was removed from the environment. | ||
| 109 | |||
| 108 | This function works by modifying `process-environment'. | 110 | This function works by modifying `process-environment'. |
| 109 | 111 | ||
| 110 | As a special case, setting variable `TZ' calls `set-time-zone-rule' as | 112 | As a special case, setting variable `TZ' calls `set-time-zone-rule' as |
| 111 | a side-effect." | 113 | a 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)) |