help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

passing data to process sentinel


From: Gordon Beaton
Subject: passing data to process sentinel
Date: 15 Sep 2006 11:17:32 GMT
User-agent: slrn/0.9.7.4 (Linux)

I run tkdiff from emacs to compare the current buffer contents with
the corresponding saved file. tkdiff needs two filenames, so I start
by storing the buffer contents to a temporary file created by
make-temp-file.

I'd like to be able to pass the name of the temporary file to a
process sentinel so it can be cleaned up after tkdiff exits, for
example by attaching the filename to the process object itself where
it can be retrieved in the sentinel. To me this seems more elegant
than storing the filename elsewhere and looking it up.

One solution I'd like to see is something like this, but of course
neither set-process-sentinel nor the sentinel itself take the
additional argument:

  (set-process-sentinel
    (start-process "tkdiff" nil "tkdiff" (buffer-file-name) temp-file)
    'my-sentinel temp-file)

  (defun my-sentinel (process event mydata) 
    (if (file-exists-p mydata) (delete-file mydata)))
    
I was hoping that something like the following might work, but
temp-file doesn't seem to get bound in the lambda function:

  (set-process-sentinel
    (start-process "tkdiff" nil "tkdiff" (buffer-file-name) temp-file)
    (lambda (process event)
      (if (file-exists-p temp-file) (delete-file temp-file))))
  
Suggestions?

/gordon

-- 
[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e


reply via email to

[Prev in Thread] Current Thread [Next in Thread]