diff options
| author | Richard M. Stallman | 1998-03-17 08:14:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-03-17 08:14:28 +0000 |
| commit | 80370c1cecf15fa2e87c515434c593287e5ff604 (patch) | |
| tree | 508b6a2b7ac184e594fa2f8cf460ef9914301108 | |
| parent | 85cac557cd0457eb6029bda3c2e90736ef04b24e (diff) | |
| download | emacs-80370c1cecf15fa2e87c515434c593287e5ff604.tar.gz emacs-80370c1cecf15fa2e87c515434c593287e5ff604.zip | |
(setenv): Simplify reading of args by passing old value as the default.
| -rw-r--r-- | lisp/env.el | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/lisp/env.el b/lisp/env.el index c0e68f63412..02e4e04b625 100644 --- a/lisp/env.el +++ b/lisp/env.el | |||
| @@ -63,29 +63,11 @@ This function works by modifying `process-environment'." | |||
| 63 | (interactive | 63 | (interactive |
| 64 | (if current-prefix-arg | 64 | (if current-prefix-arg |
| 65 | (list (read-envvar-name "Clear environment variable: " 'exact) nil t) | 65 | (list (read-envvar-name "Clear environment variable: " 'exact) nil t) |
| 66 | (let* ((var (read-envvar-name "Set environment variable: " nil)) | 66 | (let ((var (read-envvar-name "Set environment variable: " nil))) |
| 67 | (oldval (getenv var)) | ||
| 68 | newval | ||
| 69 | oldhist) | ||
| 70 | ;; Don't put the current value on the history | ||
| 71 | ;; if it is already there. | ||
| 72 | (if (equal oldval (car setenv-history)) | ||
| 73 | (setq oldval nil)) | ||
| 74 | ;; Now if OLDVAL is non-nil, we should add it to the history. | ||
| 75 | (if oldval | ||
| 76 | (setq setenv-history (cons oldval setenv-history))) | ||
| 77 | (setq oldhist setenv-history) | ||
| 78 | (setq newval (read-from-minibuffer (format "Set %s to value: " var) | ||
| 79 | nil nil nil 'setenv-history)) | ||
| 80 | ;; If we added the current value to the history, remove it. | ||
| 81 | ;; Note that read-from-minibuffer may have added the new value. | ||
| 82 | ;; Don't remove that! | ||
| 83 | (if oldval | ||
| 84 | (if (eq oldhist setenv-history) | ||
| 85 | (setq setenv-history (cdr setenv-history)) | ||
| 86 | (setcdr setenv-history (cdr (cdr setenv-history))))) | ||
| 87 | ;; Here finally we specify the args to give call setenv with. | 67 | ;; Here finally we specify the args to give call setenv with. |
| 88 | (list var newval)))) | 68 | (list var (read-from-minibuffer (format "Set %s to value: " var) |
| 69 | nil nil nil 'setenv-history | ||
| 70 | (getenv var)))))) | ||
| 89 | (if unset (setq value nil)) | 71 | (if unset (setq value nil)) |
| 90 | (if (string-match "=" variable) | 72 | (if (string-match "=" variable) |
| 91 | (error "Environment variable name `%s' contains `='" variable) | 73 | (error "Environment variable name `%s' contains `='" variable) |