From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: access a let* value whe ndefining a function? Date: Tue, 23 Oct 2018 16:05:13 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000fc03670578eae044" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gF2uy-0004oc-H9 for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 16:04:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gF2uv-0003em-F7 for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 16:04:43 -0400 Received: from mail-it1-x134.google.com ([2607:f8b0:4864:20::134]:40564) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gF2ut-0003bF-Of for emacs-orgmode@gnu.org; Tue, 23 Oct 2018 16:04:39 -0400 Received: by mail-it1-x134.google.com with SMTP id i191-v6so3739118iti.5 for ; Tue, 23 Oct 2018 13:04:36 -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: John Kitchin Cc: Org Mode --000000000000fc03670578eae044 Content-Type: text/plain; charset="UTF-8" On Tue, Oct 23, 2018 at 3:38 PM Matt Price wrote: > > > On Tue, Oct 23, 2018 at 2:32 PM John Kitchin > wrote: > >> 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. >> >> > I'm trying to use mu4e~compose-mail instead of message-compose, I guess > mostly because I want to be able to use the mu4e email address completion > features in the `To:` header. And it wouldalso be nice to save the email > to the appropriate mu folder. But I didn't seem to be able to make mu4e > bounce back to my buffer no matter what I do, and though mu4e~compose-mail > accepts a return-action argument it doesn't actually use it :-(. > > >> 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. >> >> > Can you explain to me what yo umean by "added in local mode" -- how is > that achieved? > > Meanwhile, htis is what I've done and it seems to work: > > (eval (car (read-from-string > (concat > "(advice-add 'mu4e~switch-back-to-mu4e-buffer :after > (lambda () > (switch-to-buffer > (get-buffer \"" > (buffer-name) > "\" )) > (advice-remove > 'mu4e~switch-back-to-mu4e-buffer \"om-temp-advice\")) > '((name . \"om-temp-advice\")))")))) > > seems a little baroque. Maybe what you have there is way better. I don't > really undertand backquotes and leading ocmmas even now. > > > I'd think this owuld be equivalent but the advice removal isn't working: (advice-add 'mu4e~switch-back-to-mu4e-buffer :after (eval `(lambda () (switch-to-buffer (get-buffer ,(buffer-name) )) (advice-remove 'mu4e~switch-back-to-mu4e-buffer "om-temp-advice") '((name . "om-temp-advice") )))) the naming isn't being carried out succesfully. I guess the regular quoting works differnely inside a backquote or osmething? > > >> 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 >>> >> --000000000000fc03670578eae044 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Oct 23, 2018 at 3:38 PM Matt Price <moptop99@gmail.com> wrote:

On Tue, Oct 23, 2018 at 2= :32 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
I thin= k that what you really want to do here is modify org-mime-compose so that y= ou 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 t= he heading properties after it is sent. A lot of the information gets passe= d via global variables. Maybe there is a better way to do that, I wrote tha= t code a long time ago.


I'm trying to use mu4e~compose-mail instead of message-compose,= I guess mostly because I want to be able to use the mu4e email address com= pletion features in the `To:` header.=C2=A0 And it wouldalso be nice to sav= e the email to the appropriate mu folder. =C2=A0 But I didn't seem to b= e able to make mu4e bounce back to my buffer no matter what I do, and thoug= h mu4e~compose-mail accepts a return-action argument it doesn't actuall= y use it :-(.=C2=A0=C2=A0
=C2=A0
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 informa= tion 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 ()
=C2=A0 =C2=A0 (message-box "Came from %s" = ,(current-buffer)))))
=C2=A0 (message-mail)
=C2=A0 (add= -hook 'kill-buffer-hook f nil t))

Some importa= nt notes is this hook is added in local mode, so it only affects that email= buffer.

<= div>
Can you explain to me what yo umean by "added in lo= cal mode" -- how is that achieved?

Meanwhile,= htis is what I've done and it seems to work:

=
(eval (car (read-from-string
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (concat
=C2=A0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e-buffer \"om-temp-advi= ce\"))
=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=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=C2=A0 '((name . \"om-temp-advice\")))&q= uot;))))

seems a little baroque. Maybe what you ha= ve there is way better.=C2=A0 I don't really undertand backquotes and l= eading ocmmas even now.=C2=A0


I'd think this owuld be equivalent but t= he advice removal isn't working:
(advice-add 'mu4e~s= witch-back-to-mu4e-buffer :after
=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=C2=A0=C2=A0 (eval
=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=C2=A0=C2= =A0=C2=A0 `(lambda ()
=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (switch-= to-buffer (get-buffer ,(buffer-name) ))
=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=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (advice-remove 'mu4e~switch-back-to-mu4e-buffer "om-temp= -advice")
=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '((name . &qu= ot;om-temp-advice")=C2=A0 ))))
=C2=A0=C2=A0=C2=A0
th= e naming isn't being carried out succesfully.=C2=A0 I guess the regular= quoting works differnely inside a backquote or osmething?

=C2=A0
= =C2=A0
John

-----------------------------------
= Professor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemica= l Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-= 268-7803


On Tue, Oct 23, 2018 at 1:40 PM Matt P= rice <moptop99@g= mail.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:

(let ((thisbuffer (current-buffer))
=
=C2=A0(advice-add
=C2=A0=C2=A0=C2=A0=C2=A0 'mu4e-sent-han= dler
=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 (swit= ch-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 = 9;om-sent-advice)
=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 o= f the variable during definition?

Thanks,
m
--000000000000fc03670578eae044--