sprig / org-capture-extension

A Chrome and firefox extension facilitating org-capture in emacs
MIT License
538 stars 56 forks source link

got `script error` on running applescript. #49

Open cmal opened 6 years ago

cmal commented 6 years ago

I got a script error when running the line "do shell script ..." of the applescript supplied in readme.

*ERROR*: Wrong type argument: stringp, nil

sprig commented 6 years ago

How did you run the script?

cdlm commented 6 years ago

I get it as well, it's when you double-click the application.

There is a do shell script in the on run handler which is redundant with the one in the emacsclient function. Removing it doesn't fix that however, so I'm not sure what's the actual problem.

BTW (unrelated) I'm also having weird behavior with the -c option; it opens tabs in Emacs with useless contents and does not seem to be necessary…

captainmalloc commented 5 years ago

I just installed emacsclient through brew cask and I found the same issue.

Here is my solution to better handle the case when no input is given:

on emacsclient(input)
    set cmd to "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9/emacsclient -n -c -a \"/Applications/Emacs.app/Contents/MacOS/Emacs\""
    if input is not equal to missing value then
        set cmd to cmd & " '" & input & "'"
    end if
    do shell script cmd
end emacsclient

on open location input
    emacsclient(input)
end open location

on open inputs
    repeat with raw_input in inputs
        set input to POSIX path of raw_input
        emacsclient(input)
    end repeat
end open

on run
    emacsclient(missing value)
end run

I think your EmacsClient is worth a specific GitHub to allow updating it and update its Brew Cask plugin w/o modifying Org-Capture-Extention. If you agree I can take care of it.

jishankai commented 4 years ago
on emacsclient(input)
    do shell script "/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9/emacsclient -n -c -a \"/Applications/Emacs.app/Contents/MacOS/Emacs\" " & input
end emacsclient

delete the single quote before input and after input solved the issue

niallor commented 3 years ago

@captainmalloc: Thanks for your solution, which works for me.

I agree with you that "EmacsClient is worth a specific GitHub to allow updating it and update its Brew Cask plugin".

I think that path should better be /Applications/Emacs.app/Contents/MacOS/bin/emacsclient so that whenever, as now, Brew has superseded and removed bin-x86_64-10_9, EmacsClient.app can continue to work. Brew seems to maintain bin as a link to the appropriate current bin-$ARCH-$VERSION directory, resetting it each time it upgrades Emacs.app.