git clone 'git://github.com/madnificent/ember-mode.git'
Ember-mode speeds up navigation in EmberJS projects.
NOTE: ember-mode is a work in progress. Although we use it internally, it will be extended in the future and it isn't fully functional yet. That being said, it will not destroy your code and it's nice to use.
ember-mode can be used to either generate, or navigate between files.
Let's assume you have the following files in your emberjs folder structure:
- app router.coffee - models - friend.coffee - plugin.coffee - controllers - plugins.coffee - routes - friends.coffee - plugins.coffee - friends - show.coffee
Say you are visiting the
models/friend.coffee file with
ember-mode enabled. Pressing
C-c . f r will move to
If, from there on, you enter
C-c . f c ember-mode will try to open
controllers/friends.coffee. As that doesn't exist, it'll try all of the following:
- controllers/friends.js - controllers/friend.coffee - controllers/friend.js
As none of these exist, it lists all controllers and lets you select one of them.
Say we are visiting
routes/plugins.coffee and would like to generate a
Peer model. Pressing
C-c . g m will ask for the name of the class to generate (with a default of
plugins) and the options to be passed to the generator. The default is hinted based on the current file.
Similarly, if we are visiting
routes/plugins.coffee and want to generate a controller, pressing
C-c . g c will ask for the name of the controller to generate (with a default of
plugins) and the options to be passed to the generator. In essence, pressing enter twice will generate
Say we are visiting
models/friend.coffee and want to generate the
friend route. Pressing
C-u C-c . g r will use the ember generators to generate the route and open it (without posing any questions).
Note that pressing
C-c . f r would have navigated to
routes/friends.coffee and wouldn't have found the newly generated route before.
PRO TIP: If you are using coffeescript, enable
cd path/to/your/ember-cli-project npm install ember-cli-coffeescript --save-dev
ember build and
ember test can be run with
C-c . r b and
C-c . r t
C-c . r s will either run
ember serve, or bring up
the serve buffer if already running. These commands use compilation
mode to link errors to files with line and column numbers. If the
ember serve runs in is buried, it will also notify of
build status via minibuffer messages.
If you wish to use a different prefix other than
C-c ., you may
customize the variable
clone this folder in your emacs.d folder:
mkdir -p ~/.emacs.d/ cd ~/.emacs.d git clone https://github.com/madnificent/ember-mode.git
add the folder to your load path in your
~/.emacs file if it isn't there already and require ember-mode.
(add-to-list 'load-path "~/.emacs.d/ember-mode/") (require 'ember-mode)
reload the settings, go to an ember project, enable ember-mode and try out your new keybindings!
to enable ember-mode in specific projects, create a
file in your ember project with the following:
((nil . ((mode . ember))))
(add-hook 'js-mode-hook (lambda () (ember-mode t))) (add-hook 'web-mode-hook (lambda () (ember-mode t)))