Better Emacs Commands for OS X

This is a copy of a message I just sent to Joe Wreschnig:

I read your Emacs on OS X post with interest:

http://korewanetadesu.com/software/emacs-on-os-x.html

But one of your tips didn't work!

I was using the (featurep 'ns) trick at the bottom of this page to
automatically focus new frames. But when I used the `et` command, an
existing Cocoa frame got focused, when I wanted focus instead to stay
in the term.

I fixed this problem. Here is my init.el code:

(if (featurep 'ns)
  (progn
    (defun my-focus-emacs (frame)
      "Automatically focus the emacs frame."
      (with-selected-frame frame
        (when (display-graphic-p)
          (ns-do-applescript "tell application \"Emacs\" to activate"))))
    (add-hook 'after-make-frame-functions 'my-focus-emacs)))

This replaces your code. It also has an interesting side effect: it
makes your short scripts redundant, replaceable by aliases! Note that
`emacsc` and `emacst` are still needed, of course. Here are the
suggested aliases:

alias e="emacsclient -n -a ~/bin/emacsc"
alias ec="emacsclient -n -c -a ~/bin/emacsc"
alias ecw="emacsclient -c -a ~/bin/emacsc"
alias et="emacsclient -t -a ~/bin/emacst"
alias ew="emacsclient -a ~/bin/emacsc"

This gives you all possible combinations of wait or non-wait,
new-frame or existing-frame, and frame or term.

Thanks for the tips, and I hope you enjoy these improvements!

-- 
Sean B. Palmer, http://inamidst.com/sbp/

Received on Friday, 24 January 2014 00:34:13 UTC