[OS X Emacs] Using emacsclient under OS X

Hendrik Visage hvjunk at gmail.com
Tue Oct 22 09:12:04 EDT 2013


On Fri, Oct 11, 2013 at 3:22 PM, Rainer M Krug <Rainer at krugs.de> wrote:

> Hi
>
> I have installed emacs from homebrew, and I would like to use
> emacsclient.
>
> I an using the following script, found at [1]:
>
> ,----
> | #!/bin/bash
> |
> | # This script starts emacs daemon if it is not running, opens whatever
> file
> | # you pass in and changes the focus to emacs.  Without any arguments, it
> just
> | # opens the current buffer or *scratch* if nothing else is open.  The
> following
> | # example will open ~/.bashrc
> |
> | # ec ~/.bashrc
> |
> | # You can also pass it multiple files, it will open them all.
>  Unbury-buffer
> | # will cycle through those files in order
> |
> | # The compliment to the script is et, which opens emacs in the terminal
> | # attached to a daemon
> |
> | # If you want to execute elisp, pass in -e whatever.
> | # You may also want to stop the output from returning to the terminal,
> like
> | # ec -e "(message \"Hello\")" > /dev/null
> |
> | # emacsclient options for reference
> | # -a "" starts emacs daemon and reattaches
> | # -c creates a new frame
> | # -n returns control back to the terminal
> | # -e eval the script
> |
> | # Number of current visible frames,
> | # Emacs daemon always has a visible frame called F1
> | visible_frames() {
> |   emacsclient -a "" -e '(length (visible-frame-list))'
> | }
> |
> | change_focus() {
> |   emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" >
> /dev/null
> | }
> |
> | # try switching to the frame incase it is just minimized
> | # will start a server if not running
> | test "$(visible_frames)" -eq "1" && change_focus
> |
> | if [ "$(visible_frames)" -lt  "2" ]; then # need to create a frame
> |   # -c $@ with no args just opens the scratch buffer
> |   emacsclient -n -c "$@" && change_focus
> | else # there is already a visible frame besides the daemon, so
> |   change_focus
> |   # -n $@ errors if there are no args
> |   test  "$#" -ne "0" && emacsclient -n "$@"
> | fi
> `----
>
> It works nicely from the terminal, but I have two problems:
>
> 1) Even though the script works from the terminal, it does not work when
> I call it from the automator script as it tells me that it can't find a
> running emacs server, although it should start it, which it does from
> the terminal. The same when it is already started from the terminal.
>
> 2) When using R under ESS, I can't plot, as it does not find X11
>

You'll need to download and install (and perhaps start) XQuartz for X11
support... needed since 10.6 I believe.
(X11 2.7.4 is currently the newest version available.)


>
> These two points made me think, that the emacsclient is somehow not
> running in the same environment as the graphical UI / app launchers
> are.
>
> I guess that if the first problem is solved, the second one will also be
> solved.
>

The "pure" Emacs (as from homebrew) I believe only supports X11, while
AquaMacs have been optimized for native MacOSX graphics, not via X11.


>
> Any suggestions on how I can use emacsclient under mac, via an automator
> app?
>
> Thanks,
>
> Rainer
>
>
> Footnotes:
> [1]  http://mjwall.com/blog/2013/10/04/how-i-use-emacs/
>
> --
> Rainer M. Krug
>
> email: RMKrug<at>gmail<dot>com
>
>
> _____________________________________________________________
> MacOSX-Emacs mailing list
> MacOSX-Emacs at email.esm.psu.edu
> https://email.esm.psu.edu/mailman/listinfo/macosx-emacs
> List Archives: http://dir.gmane.org/gmane.emacs.macintosh.osx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://email.esm.psu.edu/pipermail/macosx-emacs/attachments/20131022/a1b4eac9/attachment.html>


More information about the MacOSX-Emacs mailing list