Skip to content
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

Invalid function: async-start #7

Closed
binxboll opened this issue Feb 25, 2014 · 26 comments
Closed

Invalid function: async-start #7

binxboll opened this issue Feb 25, 2014 · 26 comments

Comments

@binxboll
Copy link

On Mac OS X 10.8.5, I am running GNU Emacs 24.3.1 (x86_64-apple-darwin12.5.0, Carbon Version 1.6.0 AppKit 1187.4). I have installed the latest version of org, including the org-download from contrib, Org-mode version 8.2.5h (release_8.2.5h-653-g64adcc). I have also installed the latest async via melpa.

When I drag and drop a png file onto an org buffer, I get the following error:
Invalid function: async-start

I get the same error when I invoke
M-x org-download-image
and enter a valid image url at the prompt.

Any idea what I am doing wrong?

@abo-abo
Copy link
Owner

abo-abo commented Feb 25, 2014

Try to eval (require 'async) in *scractch* with C-j. Tell me the result.

@binxboll
Copy link
Author

(require 'async)^J
async

The error message still occurs after I do this.

@abo-abo
Copy link
Owner

abo-abo commented Feb 25, 2014

Eval this in *scratch* and try again:

(defun org-download--image/command (command link filename)
  "Using COMMAND, save LINK to FILENAME.
COMMAND is a format-style string with two slots for LINK and FILENAME."
  (let ((cur-buf (current-buffer)))
    (shell-command
     (format command link
             (expand-file-name filename)))
    (with-current-buffer cur-buf
      (org-display-inline-images))))

@binxboll
Copy link
Author

It works! Does this mean the problem is with async?

@abo-abo
Copy link
Owner

abo-abo commented Feb 25, 2014

Yes, you should try to find help at https://github.com/jwiegley/emacs-async/issues if you want async.

Or you can keep using it like this, but Emacs will become stuck for the duration of
image download (which shouldn't be too long).

@mistrey
Copy link

mistrey commented Feb 26, 2014

I just ran into the same problem on a Linux computer when I tried to insert a local file. I tracked the problem down until the point where I detected that there is a difference in using org-download.el and org-download.elc. If I load the compiled file, I get the error message Invalid function: async-start. If I load the uncompiled file, everything works fine.

Maybe John Wiegley's mail introducing async can help here (see http://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00306.html).

@abo-abo
Copy link
Owner

abo-abo commented Feb 26, 2014

Can you try to re-compile org-download.elc?
I can't reproduce the issue with emacs-24.3 or 24.3.50.1 on Linux.
I can load just the elc file and it works fine.

@binxboll
Copy link
Author

What about putting a file-local variable binding ;; -*-no-byte-compile: t; -*- at the top of org-download.el ?

@abo-abo
Copy link
Owner

abo-abo commented Feb 26, 2014

What about putting a file-local variable binding ;; --no-byte-compile: t; -- at the top of org-download.el ?

I could add a work-around, but that doesn't solve the underlying problem. How did you get org-download.elc anyway?
The org install script only installs the core, and contrib/ remain uncompiled.

@mistrey
Copy link

mistrey commented Feb 26, 2014

I use make up2 to update org-mode from the Git branch master. This process creates compiled files from the contrib path as well and installs everything to /usr/share/emacs/site-lisp/org/, where I have both .el and .elc files after the installation. I just tried to compile org-download.el manually in my home directory using (byte-compile-file "/home/strey/Software/org-mode/contrib/lisp/org-download.el"). Then, after loading the compiled file with (load "/home/strey/Software/org-mode/contrib/lisp/org-download.elc") everything works fine.

The strange thing is, that the compiled files produced by make up2 and the manual process are different.

[strey@mischka org-mode]$ ls -lh /usr/share/emacs/site-lisp/org/org-download.elc /home/strey/Software/org-mode/contrib/lisp/org-download.elc
-rw-r--r-- 1 strey users 9,2K 26. Feb 17:07 /home/strey/Software/org-mode/contrib/lisp/org-download.elc
-rw-r--r-- 1 root  root  8,6K 26. Feb 17:23 /usr/share/emacs/site-lisp/org/org-download.elc

For the moment I live with the workaround

(require 'org-download "org-download.el")

but, of course, I would like to understand what make up2 really does.

@abo-abo
Copy link
Owner

abo-abo commented Feb 26, 2014

Interesting. The elc file sizes differ for me as well. Could you raise this question on org's mailing list?

@binxboll
Copy link
Author

Normally .el files in contrib/lisp are not installed with make up2. I followed the recommended procedure of inluding this line is local.mk:

ORG_ADD_CONTRIB = org-download.el*

I just tried modifying it to:

ORG_ADD_CONTRIB = org-download.el

This did not help.

I just compiled with this line in local.mk:

ORGCM = single 

This gave me a different error when invoking M-x org-download-image:

org-download--dir-2: Wrong type argument: number-or-marker-p, nil

Now when I go back to the original local.mk file, I get this same error, not Invalid function: async-start, as in the original Issue report. I don't know what is going on.

Correction: I was making a mistake in trying to insert a picture before the first headline. When I fixed that, I still got the same async error when loading the .elc file. Removing the .elc file from the org install directory fixes the problem.

@abo-abo
Copy link
Owner

abo-abo commented Feb 26, 2014

Try the workaround mentioned above:

(require 'org-download "org-download.el")

@mistrey
Copy link

mistrey commented Feb 26, 2014

I have

ORG_ADD_CONTRIB = org-checklist org-collector org-contacts org-contribdir org-dial org-eval org-mime org-notmuch org-registry ox-koma-letter org-expiry org-index org-pomodoro org-download

in my local.mk and no further options.

BTW: With this setup binxboll's proposal of a workaround by suppressing the compilation doesn't work. It leads to an error message during the make test process.

@abo-abo
Copy link
Owner

abo-abo commented Feb 26, 2014

Can't reproduce on my laptop.
I've put

 ORG_ADD_CONTRIB = org-download

and did

make up2

Everything works.

@binxboll
Copy link
Author

Perhaps byte-compiling expressions of the form

    (async-start (lambda () ...)
                 'function-to-call-when-done)

is forbidden precisely because it causes unpredictable results that may work in some cases but not in others.

@abo-abo
Copy link
Owner

abo-abo commented Feb 27, 2014

Where does it say that it's forbidden?

@mistrey
Copy link

mistrey commented Feb 27, 2014

I did some more experiments with byte-compile and batch-byte-compile.
If I put

(eval-when-compile
  (require 'async))

into org-download.el and afterwards compile with emacs-async in the load path like this

emacs -Q -batch --eval '(add-to-list '"'"'load-path ".")' --eval '(add-to-list '"'"'load-path "~/.emacs.d/emacs-async")' --eval '(batch-byte-compile)' ../contrib/lisp/org-download.el

I get a working org-download.elc with 9.2 K size. In every other case the size of the compiled file is only 8.6 K and I get the Invalid function: async-start error message.

My final conclusion is to abide by

(require 'org-download "org-download.el")

@abo-abo
Copy link
Owner

abo-abo commented Feb 27, 2014

So eval-when-compile will solve the problem?

@abo-abo
Copy link
Owner

abo-abo commented Feb 27, 2014

I see that it doesn't since make up2 doesn't know about async.

@abo-abo abo-abo reopened this Feb 27, 2014
@binxboll
Copy link
Author

Where does it say that it's forbidden?

In the link the Mistry posted:
http://lists.gnu.org/archive/html/emacs-devel/2012-06/msg00306.html

Am I interpreting that right?

@abo-abo
Copy link
Owner

abo-abo commented Feb 27, 2014

As I understand it, it's the lambda that must not be compiled (not the file).

This is a byte compiled lambda:

 (async-start (mapcar #'(lambda (x) (* x x)) '(1 2 3)))

This is not:

 (async-start (mapcar (lambda (x) (* x x)) '(1 2 3)))

@loochao
Copy link

loochao commented Jan 13, 2015

Does org-download work under Mac OSX?
I believe I've installed org-download.el correctly, but when I'm dragging and drop the image into an org buffer, all I get is the link address inserted into the buffer, no downloading events trigger.

I double checked a few things before coming here:

  • My system has both curl and download.
  • I've set the download image dir to ~/Downloads/Foo
  • The value of dnd-protocol-alist contains ("^(https?|ftp|file|nfs)://" . org-download-dnd)

The emacs I'm using is "GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2013-03-13 on bob.porkrind.org"

Could someone help? Thanks a lot.

@abo-abo
Copy link
Owner

abo-abo commented Jan 13, 2015

I don't have OSX, so I can't test it. However, it should work in
theory, since all tools used are portable.

Try using org-download-yank first: this one does everything except
dnd. Just right click and copy image url in the browser, and call
org-download-yank in Emacs. If it doesn't work, the issue is with
dnd, otherwise it's with the downloading itself.

The default org-download-backend uses url-retrieve, which is part of
Emacs, so if it doesn't work then it's a bug.

@abo-abo
Copy link
Owner

abo-abo commented Feb 24, 2015

It seems that this issue is fixed for Emacs 24.4.1.

@abo-abo abo-abo closed this as completed Feb 24, 2015
@mankoff
Copy link

mankoff commented Mar 1, 2015

I just ran into this issue using Org (latest git head), org-download (latest melpa) and emacs-mac. The solution was to delete the ELC files from the elp/org-download folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants