all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: passing data to process sentinel
Date: Fri, 15 Sep 2006 11:01:15 -0600	[thread overview]
Message-ID: <eeema3$omi$1@sea.gmane.org> (raw)
In-Reply-To: <450a8bcc$0$19463$8404b019@news.wineasy.se>

Gordon Beaton wrote:
> 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))))

Backquote is your friend:

   (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))))

-- 
Kevin

  reply	other threads:[~2006-09-15 17:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-15 11:17 passing data to process sentinel Gordon Beaton
2006-09-15 17:01 ` Kevin Rodgers [this message]
     [not found] ` <mailman.6985.1158339733.9609.help-gnu-emacs@gnu.org>
2006-09-16  7:37   ` Gordon Beaton
2006-09-18 12:42 ` Johan Bockgård
2006-09-18 13:45   ` Gordon Beaton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='eeema3$omi$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.