Mercurial > emacs
comparison lisp/env.el @ 2403:05d8916e4cde
renamed to env.el; changed setenv to putenv.
author | Noah Friedman <friedman@splode.com> |
---|---|
date | Sun, 28 Mar 1993 07:13:09 +0000 |
parents | 9e7ec92a4fdf |
children | cc774e22d049 |
comparison
equal
deleted
inserted
replaced
2402:61e1f8813d03 | 2403:05d8916e4cde |
---|---|
1 ;;; setenv.el --- functions to manipulate environment variables. | 1 ;;; env.el --- functions to manipulate environment variables. |
2 | 2 |
3 ;;; Copyright Free Software Foundation 1991 | 3 ;;; Copyright Free Software Foundation 1991 |
4 | 4 |
5 ;; Maintainer: FSF | 5 ;; Maintainer: FSF |
6 ;; Keywords: processes, unix | 6 ;; Keywords: processes, unix |
29 ;; environment variables to be passed to any sub-process run under Emacs. | 29 ;; environment variables to be passed to any sub-process run under Emacs. |
30 | 30 |
31 ;;; Code: | 31 ;;; Code: |
32 | 32 |
33 ;;;###autoload | 33 ;;;###autoload |
34 (defun setenv (variable value) | 34 (defun putenv (variable &optional value) |
35 "Set the value of the environment variable named VARIABLE to VALUE. | 35 "Set the value of the environment variable named VARIABLE to VALUE. |
36 VARIABLE and VALUE should both be strings. | 36 VARIABLE should be a string. VALUE is optional; if not provided or is |
37 `nil', the environment variable VARIABLE will be removed. | |
37 This function works by modifying `process-environment'." | 38 This function works by modifying `process-environment'." |
38 (interactive "sSet environment variable: \nsSet %s to value: ") | 39 (interactive "sSet environment variable: \nsSet %s to value: ") |
39 (if (string-match "=" variable) | 40 (if (string-match "=" variable) |
40 (error "Environment variable name contains `='") | 41 (error "Environment variable name `%s' contains `='" variable) |
41 (let ((pattern (concat "\\`" (regexp-quote (concat variable "=")))) | 42 (let ((pattern (concat "\\`" (regexp-quote (concat variable "=")))) |
42 (scan process-environment)) | 43 (scan process-environment)) |
43 (while scan | 44 (while scan |
44 (cond | 45 (cond |
45 ((string-match pattern (car scan)) | 46 ((string-match pattern (car scan)) |
46 (setcar scan (concat variable "=" value)) | 47 (if (eq nil value) |
48 (setq process-environment (delq (car scan) process-environment)) | |
49 (setcar scan (concat variable "=" value))) | |
47 (setq scan nil)) | 50 (setq scan nil)) |
48 ((null (setq scan (cdr scan))) | 51 ((null (setq scan (cdr scan))) |
49 (setq process-environment | 52 (setq process-environment |
50 (cons (concat variable "=" value) process-environment)))))))) | 53 (cons (concat variable "=" value) process-environment)))))))) |
51 | 54 |
52 (provide 'setenv) | 55 ;; Provide backward-contemptibility. |
56 (fset 'setenv 'putenv) | |
53 | 57 |
54 ;;; setenv.el ends here | 58 (provide 'env) |
59 | |
60 ;;; env.el ends here |