Mercurial > emacs
comparison lisp/env.el @ 83510:2d2f6f096f6e
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-216
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-217
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-218
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-219
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-220
Improve tq.el.
* emacs@sv.gnu.org/emacs--devo--0--patch-221
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-222
Update from CVS: src/puresize.h (PURESIZE_RATIO): Reduce to 10/6.
* emacs@sv.gnu.org/emacs--devo--0--patch-223
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-224
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-225
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-226
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-227
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-228
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-229
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-230
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-231
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-232
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-233
Update from CVS: lisp/progmodes/python.el (python-mode): Fix typo.
* emacs@sv.gnu.org/gnus--rel--5.10--patch-84
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-85
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-86
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-550
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Wed, 19 Apr 2006 16:23:46 +0000 |
parents | b98066f4aa10 d893c3bf4c3b |
children | 1321f6cfb389 |
comparison
equal
deleted
inserted
replaced
83509:24cf4bf418dc | 83510:2d2f6f096f6e |
---|---|
92 start (+ (match-beginning 0) 1))))) | 92 start (+ (match-beginning 0) 1))))) |
93 string)) | 93 string)) |
94 | 94 |
95 ;; Fixme: Should the environment be recoded if LC_CTYPE &c is set? | 95 ;; Fixme: Should the environment be recoded if LC_CTYPE &c is set? |
96 | 96 |
97 (defun setenv (variable &optional value unset substitute-env-vars frame) | 97 (defun setenv (variable &optional value substitute-env-vars frame) |
98 "Set the value of the environment variable named VARIABLE to VALUE. | 98 "Set the value of the environment variable named VARIABLE to VALUE. |
99 VARIABLE should be a string. VALUE is optional; if not provided or | 99 VARIABLE should be a string. VALUE is optional; if not provided or |
100 nil, the environment variable VARIABLE will be removed. | 100 nil, the environment variable VARIABLE will be removed. |
101 UNSET if non-nil means to remove VARIABLE from the environment. | |
102 SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment | |
103 variables in VALUE with `substitute-env-vars', where see. | |
104 Value is the new value if VARIABLE, or nil if removed from the | |
105 environment. | |
106 | 101 |
107 Interactively, a prefix argument means to unset the variable, and | 102 Interactively, a prefix argument means to unset the variable, and |
108 otherwise the current value (if any) of the variable appears at | 103 otherwise the current value (if any) of the variable appears at |
109 the front of the history list when you type in the new value. | 104 the front of the history list when you type in the new value. |
110 This function always replaces environment variables in the new | 105 This function always replaces environment variables in the new |
113 If VARIABLE is set in `process-environment', then this function | 108 If VARIABLE is set in `process-environment', then this function |
114 modifies its value there. Otherwise, this function works by | 109 modifies its value there. Otherwise, this function works by |
115 modifying either `global-environment' or the environment | 110 modifying either `global-environment' or the environment |
116 belonging to the selected frame, depending on the value of | 111 belonging to the selected frame, depending on the value of |
117 `local-environment-variables'. | 112 `local-environment-variables'. |
113 | |
114 SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment | |
115 variables in VALUE with `substitute-env-vars', which see. | |
116 This is normally used only for interactive calls. | |
117 | |
118 The return value is the new value of VARIABLE, or nil if | |
119 it was removed from the environment. | |
118 | 120 |
119 If optional parameter FRAME is non-nil, then it should be a a | 121 If optional parameter FRAME is non-nil, then it should be a a |
120 frame. If the specified frame has its own set of environment | 122 frame. If the specified frame has its own set of environment |
121 variables, this function will modify VARIABLE in it. Note that | 123 variables, this function will modify VARIABLE in it. Note that |
122 frames on the same terminal device usually share their | 124 frames on the same terminal device usually share their |
125 | 127 |
126 As a special case, setting variable `TZ' calls `set-time-zone-rule' as | 128 As a special case, setting variable `TZ' calls `set-time-zone-rule' as |
127 a side-effect." | 129 a side-effect." |
128 (interactive | 130 (interactive |
129 (if current-prefix-arg | 131 (if current-prefix-arg |
130 (list (read-envvar-name "Clear environment variable: " 'exact) nil t) | 132 (list (read-envvar-name "Clear environment variable: " 'exact) nil) |
131 (let* ((var (read-envvar-name "Set environment variable: " nil)) | 133 (let* ((var (read-envvar-name "Set environment variable: " nil)) |
132 (value (getenv var))) | 134 (value (getenv var))) |
133 (when value | 135 (when value |
134 (push value setenv-history)) | 136 (push value setenv-history)) |
135 ;; Here finally we specify the args to give call setenv with. | 137 ;; Here finally we specify the args to give call setenv with. |
136 (list var | 138 (list var |
137 (read-from-minibuffer (format "Set %s to value: " var) | 139 (read-from-minibuffer (format "Set %s to value: " var) |
138 nil nil nil 'setenv-history | 140 nil nil nil 'setenv-history |
139 value) | 141 value) |
140 nil | |
141 t)))) | 142 t)))) |
142 (if (and (multibyte-string-p variable) locale-coding-system) | 143 (if (and (multibyte-string-p variable) locale-coding-system) |
143 (let ((codings (find-coding-systems-string (concat variable value)))) | 144 (let ((codings (find-coding-systems-string (concat variable value)))) |
144 (unless (or (eq 'undecided (car codings)) | 145 (unless (or (eq 'undecided (car codings)) |
145 (memq (coding-system-base locale-coding-system) codings)) | 146 (memq (coding-system-base locale-coding-system) codings)) |
146 (error "Can't encode `%s=%s' with `locale-coding-system'" | 147 (error "Can't encode `%s=%s' with `locale-coding-system'" |
147 variable (or value ""))))) | 148 variable (or value ""))))) |
148 (if unset | 149 (and value |
149 (setq value nil) | 150 substitute-env-vars |
150 (if substitute-env-vars | 151 (setq value (substitute-env-vars value))) |
151 (setq value (substitute-env-vars value)))) | |
152 (if (multibyte-string-p variable) | 152 (if (multibyte-string-p variable) |
153 (setq variable (encode-coding-string variable locale-coding-system))) | 153 (setq variable (encode-coding-string variable locale-coding-system))) |
154 (if (and value (multibyte-string-p value)) | 154 (if (and value (multibyte-string-p value)) |
155 (setq value (encode-coding-string value locale-coding-system))) | 155 (setq value (encode-coding-string value locale-coding-system))) |
156 (if (string-match "=" variable) | 156 (if (string-match "=" variable) |