Skip to content

Commit

Permalink
Merge pull request #18 from DarwinAwardWinner/lexbind-fix
Browse files Browse the repository at this point in the history
Lexbind fix
  • Loading branch information
jwiegley committed Oct 21, 2013
2 parents 242ae73 + 93b05a9 commit f6d7a74
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
21 changes: 21 additions & 0 deletions async-test.el
Expand Up @@ -29,6 +29,7 @@

;;; Code:

(add-to-list 'load-path (file-name-directory (or load-file-name (buffer-file-name))))
(require 'async)
(require 'async-file)

Expand Down Expand Up @@ -130,6 +131,26 @@
(lambda (result)
(message "Async process done: %s" result))))

(defun async-test-7 ()
(interactive)
(message "Starting async-test-7...")
(eval
'(progn
(print
(mapcar #'async-get
(cl-loop repeat 2 collect
(async-start (lambda () t)))))
(print
(mapcar #'async-get
(cl-loop repeat 2 collect
(async-start '(lambda () t)))))
(print
(mapcar #'async-get
(cl-loop repeat 2 collect
(async-start `(lambda () ,(* 150 2)))))))
t)
(message "Finished async-test-7 successfully."))

(defsubst async-file-contents (file)
"Return the contents of FILE, as a string."
(with-temp-buffer
Expand Down
18 changes: 16 additions & 2 deletions async.el
Expand Up @@ -260,8 +260,22 @@ passed to FINISH-FUNC). Call `async-get' on such a future always
returns nil. It can still be useful, however, as an argument to
`async-ready' or `async-wait'."
(require 'find-func)
(let ((procvar (make-symbol "proc")))
`(let* ((sexp ,start-func)
(let* ((procvar (make-symbol "proc"))
;; Evaluate START-FUNC if it isn't aready a function.
(start-func
(if (functionp start-func)
start-func
(eval start-func)))
(start-func
(if (eq (car start-func) 'lambda)
(eval start-func t)
start-func)))
;; If START-FUNC is a lambda, prevent it from creating a lexical
;; closure by evaluating it in an empty lexical environment.
(when (eq (car start-func) 'lambda)
(setq start-func
(eval start-func t)))
`(let* ((sexp #',start-func)
(,procvar
(async-start-process
"emacs" (file-truename
Expand Down

0 comments on commit f6d7a74

Please sign in to comment.