annotate lisp/env.el @ 617:cde1f15848c6

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Sun, 19 Apr 1992 08:53:55 +0000
parents 4cd7543be581
children 7cbd4fcd8b0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
489
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 ;;; -*-Emacs-Lisp-*- Functions to manipulate environment variables.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 ;;; Copyright Free Software Foundation 1991
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 ;;; This file is part of GNU Emacs.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 ;;; GNU Emacs is free software; you can redistribute it and/or modify
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;;; it under the terms of the GNU General Public License as published by
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;;; the Free Software Foundation; either version 1, or (at your option)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;;; any later version.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;;; GNU Emacs is distributed in the hope that it will be useful,
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;;; GNU General Public License for more details.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;;; You should have received a copy of the GNU General Public License
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;;; along with GNU Emacs; see the file COPYING. If not, write to
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 (defun setenv (variable value)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 "Set the value of the environment variable named VARIABLE to VALUE.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 VARIABLE and VALUE should both be strings.
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 This function works by modifying process-environment."
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 (if (string-match "=" variable)
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 (error "name of environment variable contains an '=' character")
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 (let ((pattern (concat "^" (regexp-quote (concat variable "="))))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 (scan process-environment))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 (while scan
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 (cond
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ((string-match pattern (car scan))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 (setcar scan (concat variable "=" value))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (setq scan nil))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ((null (setq scan (cdr scan)))
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (setq process-environment
3d2d0362a496 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 (cons (concat variable "=" value) process-environment))))))))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
36
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
37 (provide 'setenv)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 489
diff changeset
38