org-capture-extension icon indicating copy to clipboard operation
org-capture-extension copied to clipboard

got `script error` on running applescript.

Open cmal opened this issue 6 years ago • 5 comments

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

*ERROR*: Wrong type argument: stringp, nil

cmal avatar Jun 20 '18 04:06 cmal

How did you run the script?

sprig avatar Oct 29 '18 07:10 sprig

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…

cdlm avatar Nov 22 '18 15:11 cdlm

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.

captainmalloc avatar Sep 28 '19 06:09 captainmalloc

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

jishankai avatar Mar 18 '20 06:03 jishankai

@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.

niallor avatar Apr 15 '21 19:04 niallor