emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Matt Price <moptop99@gmail.com>
Cc: org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: access a let* value whe ndefining a function?
Date: Tue, 23 Oct 2018 14:31:53 -0400	[thread overview]
Message-ID: <CAJ51ETo-Jp6QjdVEqj8L9fJrD6gbJmBrE1jrQ=fEPDdSE-ijmA@mail.gmail.com> (raw)
In-Reply-To: <CAN_Dec_2hq6ZQkG9jvmtu+u=tP93KLjv6uyv+JtErSYkW_c9vQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1936 bytes --]

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 <moptop99@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:
>
> (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
>

[-- Attachment #2: Type: text/html, Size: 2859 bytes --]

  reply	other threads:[~2018-10-23 18:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 17:40 access a let* value whe ndefining a function? Matt Price
2018-10-23 18:31 ` John Kitchin [this message]
2018-10-23 19:38   ` Matt Price
2018-10-23 20:05     ` Matt Price
2018-10-23 20:34     ` John Kitchin
2018-10-24 11:58       ` Matt Price

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to='CAJ51ETo-Jp6QjdVEqj8L9fJrD6gbJmBrE1jrQ=fEPDdSE-ijmA@mail.gmail.com' \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).