Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TorgoX (1933)


"Il est beau comme la retractilité des serres des oiseaux rapaces [...] et surtout, comme la rencontre fortuite sur une table de dissection d'une machine à coudre et d'un parapluie !" -- Lautréamont

Journal of TorgoX (1933)

Friday November 18, 2005
11:42 PM

Elisp version of system(...);

[ #27648 ]
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(...)';
    (setenv "UNDER_EMACS")
    (apply 'call-process cmd nil 0 nil args))
      (setenv "UNDER_EMACS" "1")))

(defun spawn-terminal ()
  "Spawn a new terminal window"
  (launch "gnome-terminal"))

(defun spawn-explore-pwd ()
  "Spawn a filesystem window on pwd"
  (launch "gnome-open" "."))

(defun start-current-buffer ()
  "Call 'start' on the current buffer"
  (unless (buffer-file-name) (error
    "You have to save this buffer someplace first"))
  (launch "gnome-open" (buffer-file-name)))

(defun dired-start-this-file ()
  "Call 'start' on current/selected files"
    (setenv "UNDER_EMACS")
     (function (lambda (x)
             (call-process "gnome-open" nil 0 nil x)))
     (dired-get-marked-files t current-prefix-arg)))
    (setenv "UNDER_EMACS" "1")))

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • You already have "EMACS=t" in the environment, so you don't need an extra variable to do that.

    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 ...

    • Randal L. Schwartz
    • Stonehenge
    • 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!

      • 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!
        • Randal L. Schwartz
        • Stonehenge