From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: access a let* value whe ndefining a function? Date: Tue, 23 Oct 2018 14:31:53 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002255ec0578e99606" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gF1TO-0005O7-5s for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 14:32:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gF1TM-0003ed-Mu for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 14:32:10 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:34359) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gF1TM-0003dT-8C for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 14:32:08 -0400 Received: by mail-wr1-x42f.google.com with SMTP id l6-v6so2822840wrt.1 for ; Tue, 23 Oct 2018 11:32:06 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: org-mode-email --0000000000002255ec0578e99606 Content-Type: text/plain; charset="UTF-8" I think that what you really want to do here is modify org-mime-compose so that you can use the send-actions argument to message-mail. In scimax-email.el I use that to be able to turn an org-heading into an email, send it, and then jump back to the heading to insert some information about the email into the heading properties after it is sent. A lot of the information gets passed via global variables. Maybe there is a better way to do that, I wrote that code a long time ago. Otherwise, you need to figure out how to use something like a macro that captures the current-buffer and creates a lambda function with that information in it, and attaches it to the message-buffer hook somehow. For example this will display a message-box for me after the message is sent. (let ((f `(lambda () (message-box "Came from %s" ,(current-buffer))))) (message-mail) (add-hook 'kill-buffer-hook f nil t)) Some important notes is this hook is added in local mode, so it only affects that email buffer. John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Tue, Oct 23, 2018 at 1:40 PM Matt Price wrote: > Hey, I guess this is OT. > > I'm trying to advice org-mime-org-buffer-htmlize so that it returns to the > org buffer when its done. I want to do something like this: > > (let ((thisbuffer (current-buffer)) > (advice-add > 'mu4e-sent-handler > :after (lambda (docid props) > (switch-to-buffer thisbuffer) > (advice-remove 'mu4e-sent-handler 'om-sent-advice) > ) '((name . 'om-sent-advice))) > > but by the time the hook is run, the (let) has long since lapsed, and > thisbuffer is no longer defined. Can I force evaluation of the variable > during definition? > > Thanks, > m > --0000000000002255ec0578e99606 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think that what you really want to do h= ere is modify org-mime-compose so that you can use the send-actions argumen= t to message-mail. In scimax-email.el I use that to be able to turn an org-= heading into an email, send it, and then jump back to the heading to insert= some information about the email into the heading properties after it is s= ent. A lot of the information gets passed via global variables. Maybe there= is a better way to do that, I wrote that code a long time ago.

Otherwise, you need to figure out how to use something like a macro= that captures the current-buffer and creates a lambda function with that i= nformation in it, and attaches it to the message-buffer hook somehow. For e= xample this will display a message-box for me after the message is sent.

(let ((f `(lambda ()
=C2=A0 =C2=A0 (message-box "Came from %s"= ,(current-buffer)))))
=C2=A0 (message-mail)
=C2=A0 (ad= d-hook 'kill-buffer-hook f nil t))

Some import= ant notes is this hook is added in local mode, so it only affects that emai= l buffer.

John

-------------= ----------------------
Professor John Kitchin=C2=A0
Doherty Hall A207= F
Department of Chemical Engineering
Carnegie Mellon University
Pi= ttsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchi= ngroup.cheme.cmu.edu



On Tue, Oct = 23, 2018 at 1:40 PM Matt Price <mo= ptop99@gmail.com> wrote:
Hey, I guess this is OT.

=
I'm trying to advice org-mime-org-buffer-htmlize so that it = returns to the org buffer when its done. I want to do something like this:<= /div>

(let ((thisbuffer (current-buffer))
= =C2=A0(advice-add
=C2=A0=C2=A0=C2=A0=C2=A0 'mu4e-sent-handler
=C2= =A0=C2=A0=C2=A0=C2=A0 :after (lambda (docid props)
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (switch-to-buffer= thisbuffer)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (advice-remove 'mu4e-sent-handler 'om-sent-ad= vice)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 ) '((name . 'om-sent-advice)))

=
but by the time the hook is run, the (let) has long since lapsed= , and thisbuffer is no longer defined. Can I force evaluation of the variab= le during definition?

Thanks,
m
--0000000000002255ec0578e99606--