I am using https://github.com/sprig/org-capture-extension which is a cool Chrome extension to capture links while browsing. The setup on OS X requires defining an Applescript application which is called by the extension. Here is the code I use:
on emacsclient(input) display dialog input try do shell script "/usr/local/Cellar/emacs-plus/25.2/bin/emacsclient -n '" & input & "'" on error e number n my logit("OOPs: " & e & " " & n, "Emacsclient") end try end emacsclient to logit(log_string, log_file) do shell script ¬ "echo `date '+%Y-%m-%d %T: '`\"" & log_string & "\" >> $HOME/Library/Logs/" & log_file & ".log" end logit 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 do shell script emacsclient("") end run
There is an Emacs running in daemon mode which is started upon initial login in the system. The problem I have is the emacsclient run in the script cannot find the server's socket: This socket is located inside my
$TMPDIR which is set by OS X and is not available to scripts run through applescripts
shell script action.
How can I solve this conundrum? I need either to run the daemon with a fixed socket file so that I can pass that to the client, or retrieve
$TMPDIR from within applescript.