<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 3:22 PM, Rainer M Krug <span dir="ltr"><<a href="mailto:Rainer@krugs.de" target="_blank">Rainer@krugs.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi<br>
<br>
I have installed emacs from homebrew, and I would like to use<br>
emacsclient.<br>
<br>
I an using the following script, found at [1]:<br>
<br>
,----<br>
| #!/bin/bash<br>
|<br>
| # This script starts emacs daemon if it is not running, opens whatever file<br>
| # you pass in and changes the focus to emacs.  Without any arguments, it just<br>
| # opens the current buffer or *scratch* if nothing else is open.  The following<br>
| # example will open ~/.bashrc<br>
|<br>
| # ec ~/.bashrc<br>
|<br>
| # You can also pass it multiple files, it will open them all.  Unbury-buffer<br>
| # will cycle through those files in order<br>
|<br>
| # The compliment to the script is et, which opens emacs in the terminal<br>
| # attached to a daemon<br>
|<br>
| # If you want to execute elisp, pass in -e whatever.<br>
| # You may also want to stop the output from returning to the terminal, like<br>
| # ec -e "(message \"Hello\")" > /dev/null<br>
|<br>
| # emacsclient options for reference<br>
| # -a "" starts emacs daemon and reattaches<br>
| # -c creates a new frame<br>
| # -n returns control back to the terminal<br>
| # -e eval the script<br>
|<br>
| # Number of current visible frames,<br>
| # Emacs daemon always has a visible frame called F1<br>
| visible_frames() {<br>
|   emacsclient -a "" -e '(length (visible-frame-list))'<br>
| }<br>
|<br>
| change_focus() {<br>
|   emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null<br>
| }<br>
|<br>
| # try switching to the frame incase it is just minimized<br>
| # will start a server if not running<br>
| test "$(visible_frames)" -eq "1" && change_focus<br>
|<br>
| if [ "$(visible_frames)" -lt  "2" ]; then # need to create a frame<br>
|   # -c $@ with no args just opens the scratch buffer<br>
|   emacsclient -n -c "$@" && change_focus<br>
| else # there is already a visible frame besides the daemon, so<br>
|   change_focus<br>
|   # -n $@ errors if there are no args<br>
|   test  "$#" -ne "0" && emacsclient -n "$@"<br>
| fi<br>
`----<br>
<br>
It works nicely from the terminal, but I have two problems:<br>
<br>
1) Even though the script works from the terminal, it does not work when<br>
I call it from the automator script as it tells me that it can't find a<br>
running emacs server, although it should start it, which it does from<br>
the terminal. The same when it is already started from the terminal.<br>
<br>
2) When using R under ESS, I can't plot, as it does not find X11<br></blockquote><div><br></div><div>You'll need to download and install (and perhaps start) XQuartz for X11 support... needed since 10.6 I believe.<br>
(X11 2.7.4 is currently the newest version available.) <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
These two points made me think, that the emacsclient is somehow not<br>
running in the same environment as the graphical UI / app launchers<br>
are.<br>
<br>
I guess that if the first problem is solved, the second one will also be<br>
solved.<br></blockquote><div><br></div><div>The "pure" Emacs (as from homebrew) I believe only supports X11, while AquaMacs have been optimized for native MacOSX graphics, not via X11.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<br>
Any suggestions on how I can use emacsclient under mac, via an automator<br>
app?<br>
<br>
Thanks,<br>
<br>
Rainer<br>
<br>
<br>
Footnotes:<br>
[1]  <a href="http://mjwall.com/blog/2013/10/04/how-i-use-emacs/" target="_blank">http://mjwall.com/blog/2013/10/04/how-i-use-emacs/</a><br>
<span class=""><font color="#888888"><br>
--<br>
Rainer M. Krug<br>
<br>
email: RMKrug<at>gmail<dot>com<br>
<br>
<br>
_____________________________________________________________<br>
MacOSX-Emacs mailing list<br>
<a href="mailto:MacOSX-Emacs@email.esm.psu.edu">MacOSX-Emacs@email.esm.psu.edu</a><br>
<a href="https://email.esm.psu.edu/mailman/listinfo/macosx-emacs" target="_blank">https://email.esm.psu.edu/mailman/listinfo/macosx-emacs</a><br>
List Archives: <a href="http://dir.gmane.org/gmane.emacs.macintosh.osx" target="_blank">http://dir.gmane.org/gmane.emacs.macintosh.osx</a><br>
</font></span></blockquote></div><br></div></div>