-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async-inject-function? #122
Comments
Jethro Kuan <notifications@github.com> writes:
I have a few functions defined outside of my async-start call, that's
used both synchronously and asynchronously. I'd like these functions
to be available within the async-start lambda, would it be possible to
add a async-inject-function similar to what async-inject-variable
does?
The simplest way is to put your functions inside a file and require or
load file in your async-start lambda, another way is to define your
function as a defalias always in your async-start lambda:
Example:
(defun tv/shuffle-vector (vector)
"Shuffle VECTOR."
(cl-loop with len = (1- (length vector))
while (>= len 0)
for rand = (random (1+ len))
for old = (aref vector rand)
do (progn
(aset vector rand (aref vector len))
(aset vector len old)
(setq len (1- len)))
finally return vector))
(async-start `(lambda ()
(defalias 'tv/shuffle-vector
,(symbol-function 'tv/shuffle-vector))
(tv/shuffle-vector ["a" "b" "c" "d" "e" "f" "g" "h"]))
(lambda (result)
(message "Result: %S" result)))
…--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
|
Thanks a lot @thierryvolpiatto , I'll adopt the latter! |
jethrokuan
added a commit
to org-roam/org-roam
that referenced
this issue
Feb 13, 2020
See jwiegley/emacs-async#122 for alternative method
jethrokuan
added a commit
to org-roam/org-roam
that referenced
this issue
Feb 13, 2020
See jwiegley/emacs-async#122 for alternative method Signed-off-by: Jethro Kuan <jethrokuan95@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a few functions defined outside of my
async-start
call, that's used both synchronously and asynchronously. I'd like these functions to be available within theasync-start
lambda, would it be possible to add aasync-inject-function
similar to whatasync-inject-variable
does?see org-roam/org-roam#72
The text was updated successfully, but these errors were encountered: