comparison lisp/process.el @ 930:eaedf30d9d76

[xemacs-hg @ 2002-07-23 08:34:59 by youngs] 2002-07-15 Jerry James <james@xemacs.org> * make-docfile.c: Change whitespace and organization to reduce the size of the diff against FSF Emacs sources and synch to Emacs 21.2. Remove unused DO_REALLOC. Mark XEmacs changes and additions more clearly. Reintroduce previously deleted Emacs code inside #if 0 ... #endif. * make-docfile.c (next_extra_elc): Replace goto with do-while. * make-docfile.c (main): Put XEmacs-only args in one place. * make-docfile.c (write_c_args): Change buff to buf to match Emacs. Replace pointer arithmetic with simpler array syntax. * make-docfile.c (scan_c_file): Note that DEFSIMPLE and DEFPRED no longer exist. Correct the "name too long" test (off by one). Die with message if a DEFUN has no docstring instead of hanging. * make-docfile.c (scan_lisp_file): Introduce while loops used in Emacs sources to skip consecutive blank lines. 2002-07-21 John Paul Wallington <jpw@xemacs.org> * process.el (substitute-env-vars): New function; sync with GNU Emacs 21.1.50. (setenv): Add optional arg SUBSTITUTE-ENV-VARS; sync with GNU Emacs 21.1.50. 2002-07-20 Mike Sperber <mike@xemacs.org> * eval.c (run_post_gc_hook): Use more correct flags when running post-gc-hook. 2002-07-20 Mike Sperber <mike@xemacs.org> * process-unix.c (child_setup): Don't try to close file descriptors for chid process once again---it's already being done in close_process_descs. (unix_create_process): Call begin_dont_check_for_quit to inhibit unwanted interaction (and thus breaking of X event synchronicity) in the child. 2002-07-15 Jerry James <james@xemacs.org> * lisp.h: Make Qdll_error visible globally. * symbols.c (check_sane_subr): Revert 2002-06-26 change. Check only if !initialized. * symbols.c (check_module_subr): Add parameter. Duplicate check_sane_subr checks, but signal an error instead of asserting. * symbols.c (defsubr): Use check_module_subr parameter. * symbols.c (defsubr_macro): Ditto.
author youngs
date Tue, 23 Jul 2002 08:35:11 +0000
parents 5fc81edb7a38
children 23eaac87b4b0
comparison
equal deleted inserted replaced
929:0c272be3414c 930:eaedf30d9d76
533 nil mustmatch nil 'read-envvar-name-history)) 533 nil mustmatch nil 'read-envvar-name-history))
534 534
535 ;; History list for VALUE argument to setenv. 535 ;; History list for VALUE argument to setenv.
536 (defvar setenv-history nil) 536 (defvar setenv-history nil)
537 537
538 (defun setenv (variable &optional value unset) 538 (defun substitute-env-vars (string)
539 "Substitute environment variables referred to in STRING.
540 `$FOO' where FOO is an environment variable name means to substitute
541 the value of that variable. The variable name should be terminated
542 with a character not a letter, digit or underscore; otherwise, enclose
543 the entire variable name in braces. Use `$$' to insert a single
544 dollar sign."
545 (let ((start 0))
546 (while (string-match
547 ;; XEmacs change - FSF use their rx macro to generate this regexp
548 "\\(?:\\$\\(\\(?:[a-zA-Z0-9_]\\)+\\)\\)\\|\\(?:\\${\\(\\(?:.\\|\n\\)*?\\)}\\)\\|\\$\\$"
549 string start)
550 (cond ((match-beginning 1)
551 (let ((value (getenv (match-string 1 string))))
552 (setq string (replace-match (or value "") t t string)
553 start (+ (match-beginning 0) (length value)))))
554 ((match-beginning 2)
555 (let ((value (getenv (match-string 2 string))))
556 (setq string (replace-match (or value "") t t string)
557 start (+ (match-beginning 0) (length value)))))
558 (t
559 (setq string (replace-match "$" t t string)
560 start (+ (match-beginning 0) 1)))))
561 string))
562
563 (defun setenv (variable &optional value unset substitute-env-vars)
539 "Set the value of the environment variable named VARIABLE to VALUE. 564 "Set the value of the environment variable named VARIABLE to VALUE.
540 VARIABLE should be a string. VALUE is optional; if not provided or is 565 VARIABLE should be a string. VALUE is optional; if not provided or is
541 `nil', the environment variable VARIABLE will be removed. 566 `nil', the environment variable VARIABLE will be removed.
567
568 UNSET, if non-nil, means to remove VARIABLE from the environment.
569 SUBSTITUTE-ENV-VARS, if non-nil, means to substitute environment
570 variables in VALUE using `substitute-env-vars'.
542 571
543 Interactively, a prefix argument means to unset the variable. 572 Interactively, a prefix argument means to unset the variable.
544 Interactively, the current value (if any) of the variable 573 Interactively, the current value (if any) of the variable
545 appears at the front of the history list when you type in the new value. 574 appears at the front of the history list when you type in the new value.
546 575
551 (let ((var (read-envvar-name "Set environment variable: " nil))) 580 (let ((var (read-envvar-name "Set environment variable: " nil)))
552 ;; Here finally we specify the args to call setenv with. 581 ;; Here finally we specify the args to call setenv with.
553 (list var (read-from-minibuffer (format "Set %s to value: " var) 582 (list var (read-from-minibuffer (format "Set %s to value: " var)
554 nil nil nil 'setenv-history 583 nil nil nil 'setenv-history
555 (getenv var)))))) 584 (getenv var))))))
556 (if unset (setq value nil)) 585 (if unset
586 (setq value nil)
587 (if substitute-env-vars
588 (setq value (substitute-env-vars value))))
557 (if (string-match "=" variable) 589 (if (string-match "=" variable)
558 (error "Environment variable name `%s' contains `='" variable) 590 (error "Environment variable name `%s' contains `='" variable)
559 (let ((pattern (concat "\\`" (regexp-quote (concat variable "=")))) 591 (let ((pattern (concat "\\`" (regexp-quote (concat variable "="))))
560 (case-fold-search nil) 592 (case-fold-search nil)
561 (scan process-environment) 593 (scan process-environment)