Dear Log,
More Emacs fun. I'm learnding elisps!!!!
(setenv "UNDER_EMACS" "1")
; A handy envvar for letting some programs know
; when they're being called via shell-command
(defun launch (cmd &rest args)
"Launch cmd with given arguments, not waiting for it completion, nor saving its output."
; sort of like perl 'system(...)';
(unwind-protect
(progn
(setenv "UNDER_EMACS")
(apply 'call-process cmd nil 0 nil args))
(setenv "UNDER_EMACS" "1")))
(defun spawn-terminal ()
"Spawn a new terminal window"
(interactive)
(launch "gnome-terminal"))
(defun spawn-explore-pwd ()
"Spawn a filesystem window on pwd"
(interactive)
(launch "gnome-open" "."))
(defun start-current-buffer ()
"Call 'start' on the current buffer"
(interactive)
(unless (buffer-file-name) (error
"You have to save this buffer someplace first"))
(save-buffer)
(launch "gnome-open" (buffer-file-name)))
(defun dired-start-this-file ()
"Call 'start' on current/selected files"
(interactive)
(unwind-protect
(progn
(setenv "UNDER_EMACS")
(mapc
(function (lambda (x)
(call-process "gnome-open" nil 0 nil x)))
(dired-get-marked-files t current-prefix-arg)))
(setenv "UNDER_EMACS" "1")))
If you want to temporarily get rid of that, setenv does a lot more than you need, including pushing your temp changes into setenv-history. Look at localizing the process-environment variable, and simply modifying it to a new value. For example (slightly untested):
(let ((process-environment (cons "FOO=bar" process-environment)))
... your code ...
)
Re:From an old elisp hacker...
TorgoX on 2005-11-19T12:12:00
You already have "EMACS=t" in the environment,I don't see that when I shell-command "printenv" or do (getenv "EMACS"). Are you using Xemacs? I'm using GNU Emacs 21.3.1.
That's a handy trick with localizing process-environment tho!
Re:From an old elisp hacker...
merlyn on 2005-11-19T12:17:46
EMACS=t is apparently only when I start a shell. Must be a function of shell mode. (Time passes.) Oh, it's defined in comint-exec-1. There's a good example of manipulating a local process-environment there too! Bonus!