Emacs For Mac Os X



  1. Emacs For Mac Os X
  2. Emacs For Mac Os X Catalina

I wanted a nice experience using Emacs for Mac OS X. By 'nice' Imean:

How to find the 'emacs Psychotherapist' Easter Egg in Mac OS X. Go to finder then applications. Go to the Utilities folder and open Terminal. When it has started up type in 'emacs' (without speech marks) and press enter. Then press x and escape together. Then type in 'doctor' (again without speech. Download Emacs distribution for Mac OS X (Carbon) for free. This project delivers a binary distribution of GNU Emacs for Mac OS X (Carbon).

  • Emacs runs in server mode. It's started like other OS X software by Launch Services.
  • I can connect to it with graphical or terminal-based clients easily.
  • Graphical clients use Cocoa and not X11.
  • There's an icon on my dock to pop up a new graphical frame.
  • There's a shell command I can type to open a new graphical frame.
  • There's something I can type into Spotlight to open a new graphical frame.
  • If the server is dead for some reason, there's a way to start it in a small number of clicks.
  • If the server is dead for some reason, as many as the above features as possible still work.
  • It's easy, but not the default, to start standalone (non-client) Emacs instances as well.

You too can bring several hours and three separate scripting tools tobear on this, or follow the simple (hah hah) instructions below.

First, install Emacs For Mac OS X. The Emacs that comes with OS X isold and crusty, and the one at that site is new and Cocoa-ready andRetina-enabled and so on. Put it in /Applications - if you put itsomewhere else, you'll need to correct all the other scripts I'mmentioning in this post.

Emacs Server at Login

Open up the AppleScript Editor. If you're an Emacs user this probablylooks awful and confusing to you. Paste the following into it:

Press ⌘K to compile it, then ⌘S and save it in/Applications/Development. (This subfolder keeps your Applicationsmenu clean, and has an important effect on sort order later.) To giveit a nice icon, select the original Emacs.app; press ⌘I; click theicon in the top-left; press ⌘C; select on your new Emacs Server.appbundle; press ⌘I; click the icon in the top-left; press ⌘V.

Open up System Preferences > Users & Groups > Login Items and nowyou can press the + button and choose Emacs Server.

The server is invisible until you first connect a client to it. Thenit will appear in the dock, as the regular Emacs.app.

New Frame Dock Icon

Emacs

To make a dock icon that opens up a new Emacs frame - a client if theserver is available, a standalone instance otherwise - create thefollowing script in the AppleScript Editor and save it as anApplication named Emacs Client. in /Applications/Development.

Then drag this from the Applications folder to your dock. This willalso make it so typing emacs into Spotlight selects this as thefirst item ('Development' sorts before 'Emacs', 'Client' sorts before'Server').

If connected to the server, this opens up a new client frame eachclick, by design. To just raise existing frames, click the otherEmacs icon on the dock, representing the running application.

Server-aware Shell Scripts

I put these in ~/local/bin. You'll need to add that to your $PATHif you haven't already. First, two simple ones. These will start newinstances, not clients, but they're necessary to properly handle shellarguments for fallbacks for clients. They're also nice to have if youactually want to start a new instance.

Start a new Cocoa instance - emacsc:

Emacs For Mac Os X

Start a new terminal instance - emacst:

Now for something ma little ore complicated - ec, start a Cocoaclient or fall back to a new instance (via the above emacsc) if theserver is unavailable.

Similarly, et, for a terminal client or new terminal instance.

Emacs For Mac Os X

Why are ec and et scripts instead of aliases? Many tools will failif $EDITOR does not resolve to an actual executable somewhere in$PATH because they invoke the tool directly instead of invoking ashell to run it.

Finally: Some aliases for ~/.bash_profile, to override the ancientversion of Emacs that Mac OS X comes with by default.

Mac

Activate Emacs on New Frames

If you start emacsc or ec from Terminal, Mac OS X doesn't realizeyou probably want to switch focus to the Emacs session automatically.There are also plenty of other ways you might start Emacs besidestyping a command into Terminal, and you probably want the new framesfocused then as well.

Emacs

To do this, we can take advantage of the ns features in Emacs Lispand the frame-creation hooks. Add the following to your ~/.emacs orsome file it loads:

Now anything that opens or selects a frame will also activate Emacsfor Finder. The featurep check means this is harmless to load onnon-OS X platforms, and ns-raise-emacs is not (interactive) forreasons that will be self-evident if you think about them.

Remaining Issues

Launch Services is happy to start the Emacs Server instance but losestrack of it afterwards. This is mostly harmless but annoying.

The second Emacs icon on the dock (the one for the main Emacs.apprather than your custom Emacs Client.app) behaves oddly when noframes are visible. Its menu bar and context menu don't work, and youcan't start a new frame from it directly. This is likely an issuebecause both Emacs and Finder assume any graphical application has atleast one main window / frame, even if it might not be visible.

Emacs For Mac Os X

(Thanks to Dan Gerrity for pointing out a typo in the original postedemacst script, and Sean B. Palmer for Emacs Lisp improvements thatled to much simpler shell scripts.)

Emacs For Mac Os X Catalina

  • iOS
  • macOS
  • watchOS
  • tvOS
  • Swift
  • Man Pages
  • .NET Framework
  • ActionScript
  • Akka
  • Android
  • Angular
  • Ansible
  • Apache
  • Appcelerator Titanium
  • AppleScript
  • Arduino
  • Backbone
  • Bash
  • Boost
  • Bootstrap
  • Bourbon
  • Bourbon Neat
  • C
  • C++
  • CakePHP
  • Cappuccino
  • Chai
  • Chef
  • Clojure
  • CMake
  • Cocos2D
  • Cocos2D-X
  • CodeIgniter
  • CoffeeScript
  • ColdFusion
  • Common Lisp
  • Compass
  • Cordova
  • Corona
  • CouchDB
  • Craft
  • CSS
  • D3.js
  • Dart
  • Django
  • Docker
  • Doctrine ORM
  • Dojo Toolkit
  • Drupal
  • Elasticsearch
  • Elixir
  • Emacs Lisp
  • Ember.js
  • Emmet.io
  • Erlang
  • Express.js
  • Expression Engine
  • ExtJS
  • Flask
  • Font Awesome
  • Foundation
  • GLib
  • Go
  • Gradle
  • Grails
  • Groovy
  • Grunt
  • Gulp
  • Haml
  • Handlebars
  • Haskell
  • HTML
  • Ionic
  • Jasmine
  • Java SE
  • Java EE
  • JavaScript
  • Jekyll
  • Jinja
  • Joomla
  • jQuery
  • jQuery Mobile
  • jQuery UI
  • Julia
  • Knockout.js
  • Kobold2D
  • Laravel
  • LaTeX
  • Less
  • lodash
  • Lua
  • Marionette.js
  • Matplotlib
  • Meteor
  • Mocha
  • MomentJS
  • MongoDB
  • Mongoose
  • Mono
  • MooTools
  • MySQL
  • Nginx
  • Node.js
  • NumPy
  • OCaml
  • OpenCV
  • OpenGL
  • Pandas
  • Perl
  • Phalcon
  • PhoneGap
  • PHP
  • PHPUnit
  • Play Framework
  • Polymer.dart
  • PostgreSQL
  • Processing.org
  • Prototype
  • Pug
  • Puppet
  • Python
  • Qt
  • R
  • Racket
  • React
  • Redis
  • RequireJS
  • Ruby
  • Ruby on Rails
  • Rust
  • Sails.js
  • Sass
  • SaltStack
  • Scala
  • SciPy
  • Semantic UI
  • Sencha Touch
  • Sinon
  • Smarty
  • Sparrow
  • Spring Framework
  • SproutCore
  • SQLAlchemy
  • SQLite
  • Statamic
  • Stylus
  • Susy
  • SVG
  • Symfony
  • Tcl
  • Tornado
  • Twig
  • Twisted
  • TypeScript
  • TYPO3
  • Underscore.js
  • Unity 3D
  • Vagrant
  • Vim
  • VMware vSphere
  • Vue.js
  • WordPress
  • Xamarin
  • Xojo
  • XSLT
  • Yii
  • YUI
  • Zend Framework
  • Zepto.js