This is my emacs configuration files, the most different with previous version is now I use el-get as package manager.
Many packages are installing from source. so you need to install xcode command line tools first to compile some source code.
just type command below and fllow the instructions.
and then click install button.
verify your install by
$ xcode-select -p /Library/Developer/CommandLineTools
a simple way, you can directly install emacs and all it’s dependency by script below
\curl -sSL https://raw.githubusercontent.com/ripple0328/.emacs.d/master/bin/install.sh | bash
all configuration described by section below will be execute by script above automatically.
if you have already install this emacs, you can always update the configuration by
cd ~/.emacs.d/ git pull ./bin/install-local.sh
basic key binding notes
key binding setting
advice for mac users, switch caplock and left control:
System preferences-> keyboard -> keyboard tab -> modifier keys(right buttom corner)-> change Caps Lock Key -> ^Control
naming and custom keybingding without conflicts must be the hardest thing in emacs configuration
here only descript custom or package provide function keybinding. for emacs buildin editing please read the tutorial by C-h t. or here
usually edit keybinding are global.
|C-c SPC||ace-jump-word-mode||enter first character of a word, select the highlighted key to move to it.|
|C-u C-c SPC||ace-jump-char-mode||enter a character for query, select the highlighted key to move to it.|
|C-u C-u C-c SPC||ace-jump-line-mode||each non-empty line will be marked, select the highlighted key to move to it.|
|C-=||er/expand-region||increase selected region by unit|
|C-c p f,||Display a list of all files in the project. With a prefix argument it will clear the cache first.|
|C-c p d,||Display a list of all directories in the project. With a prefix argument it will clear the cache first.|
|C-c p T,||Display a list of all test files(specs, features, etc) in the project.|
|C-c p l,||Display a list of all files in a directory (that’s not necessarily a project)|
|C-c p g,||Run grep on the files in the project.|
|C-c p b,||Display a list of all project buffers currently open.|
|C-c p o,||Runs multi-occur on all project buffers currently open.|
|C-c p r,||Runs interactive query-replace on all files in the projects.|
|C-c p i,||Invalidates the project cache (if existing).|
|C-c p R,||Regenerates the projects TAGS file.|
|C-c p k,||Kills all project buffers.|
|C-c p D,||Opens the root of the project in dired.|
|C-c p e,||Shows a list of recently visited project files.|
|C-c p a,||Runs ack on the project. Requires the presence of ack-and-a-half.|
|C-c p A,||Runs ag on the project. Requires the presence of ag.el.|
|C-c p c,||Runs a standard compilation command for your type of project.|
|C-c p p,||Runs a standard test command for your type of project.|
|C-c p z,||Adds the currently visited to the cache.|
|C-c p s,||Display a list of known projects you can switch to.|
|⌘-t||Go to File|
|⇧⌘-t||Go to Symbol|
|⌘-t||Go to Line|
|⇧⌘-l||Select Line (or expand Selection to select lines)|
|⌘-/||Comment Line (or Selection/Region)|
|⌘-]||Shift Right (currently indents region)|
|⌘-[||Shift Left (not yet implemented)|
|⌘-RET||Insert Newline at Line’s End|
|⌥⌘-T||Reset File Cache (for Go to File)|
version control (magit)
|C-c m||magit-status||Open a Magit status buffer for the Git repository containing DIR.|
|magit-add-remote||add the remote and fetch it(git remote add REMOTE URL)|
|C-u i||ignore by patten not specific item|
|C-c , t||toggle back and forth between a spec and its target|
|C-c , v||verify the spec file associated with the current buffer|
|C-c , s||verify the example defined at the point of the current buffer|
|C-c , r||re-run the last verification process|
|C-c , d||toggle the pendingness of the example at the point|
|C-c , a||run all specifications for project|
|C-c C-r p||rubocop-check-project||Runs RuboCop on the entire project|
|C-c C-r d||rubocop-check-directory||Prompts from a directory on which to run RuboCop|
|C-c C-r f||rubocop-check-current-file||Runs RuboCop on the currently visited file|
|C-c C-r P||rubocop-autocorrect-project||Runs auto-correct on the entire project|
|C-c C-r D||rubocop-autocorrect-directory||Prompts for a directory on which to run auto-correct|
|C-c C-r F||rubocop-autocorrect-current-file||Runs auto-correct on the currently visited file.|
using emacs you only need to known above
Since emacs version 24, emacs has buildin elpa as it’s default package system. But official repo can not contain every package either every new versions of a package. Not every author like to contribute his package to the official repo. most of them just put it on github or even his own blog.
el-get support almost every kind a package source, including elpa, wiki, github, ftp and so on. So el-get has more abundant package resouces.
now you only need to configure and manage your package recipe instead of whole package. there is already most recipe in hand contributed by others. based on package recipes, maintainance and update became more easier.
el-get also support customized initial script.
most important, el-get is vert activity by now. and it is the most powerfull packge manager as I know.
emacs that comes with osx is still 22.1.1, even you have upgrade your operation system 10.9. it pretty old and difficult to use. why not apple just do not pre-bundled such emacs.
for mac users those who don’t want to have heavy configuration, my suggestion is emacs for osx, its have advantage against others in such field:
- cocoa not X11
that is the default version installed by install section.
emacsforosx have different color behaviour. so the color theme may not the same as you saw them in a screen snapshot.
for mac user those want to toss of emacs, just brew install it by source code. you can control many things through pass different compile flags.
brew install emacs --cocoa brew linkapps #make symbolic to /Applications/ # let some command like emacsclient also available at /Applications/Emacs.app/ location ln -s /usr/local/Cellar/emacs/HEAD/bin/ /Applications/Emacs.app/Contents/MacOS/bin
for Alfred to index Emacs app add usr/local/Cellar into Alfred’s search scope to find Emacs
command line launch
if you want to lanuch emacs from command line, add such command alias to your .bash_profile or .zshrc
alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs -nw'
or add a script file /usr/bin/emacs this is better I think, cas many third party package would assume the emacs path to be ’usr/bin‘， for example magit. so only terminal know how to find executable emacs but not emacs itself if you only add a alias.
#!/bin/bash /Applications/Emacs.app/Contents/MacOS/Emacs -nw
for those using emacsosxna
git clone https://github.com/ferlatte/emacs-daemon-osx.git cd emacs-daemon-osx cp org.gnu.emacs.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/org.gnu.emacs.plist make rm -r /Applications/emacs-client.app cp -r emacs-client.app /Applications
- create a plist file in ~/Library/LaunchAgents, for exapmle org.gnu.emacs.daemon.plist
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>gnu.emacs.daemon</string> <key>ProgramArguments</key> <array> <string>/usr/local/Cellar/emacs/HEAD/Emacs.app/Contents/MacOS/Emacs</string> <string>--daemon</string> </array> <key>RunAtLoad</key> <true/> <key>ServiceDescription</key> <string>Gnu Emacs Daemon</string> <key>UserName</key> <string>qingbo</string> </dict> </plist>
next time you login, os will automatic launch program descript in LaunchAgents.
making a shortcut in you .bash_profile
alias e='emacsclient -t'
- create a applescript. paste below
tell application "Terminal" do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon" endtell
add this to users login tem
packages I use frequenctly. I will eventually add a description to the usage of every packge if have time.
with * prefix is package not used currently
Modern on-the-fly syntax checking
inf-ruby provides a REPL buffer connected to a Ruby subprocess.
Did you use sublime before, this package provide the same thing like sublime guideline indentation
- highlight-indentation-mode displays guidelines indentation (space indentation only).
- highlight-indentation-current-column-mode displays guidelines for the current-point indentation (space indentation only).
- (set-face-background ‘highlight-indentation-face “#e3e3d3”)
- (set-face-background ‘highlight-indentation-current-column-face “#c3b3b3”)
A modern list api for Emacs. No ‘cl required
A simple Emacs interface for RuboCop which is a Ruby static code analyzer.
This minor mode exists to mimick TextMate’s awesome
- ;; etags-extension
- ;; anything-etags
letting you write HTML based on CSS selectors.
C-j: place point in a zencoding snippet and press C-j to expand it C-c C-j: you’ll transform your snippet into the appropriate tag structure.
- ;; magithub
- ;; twittering-mode
powerline theme for emacs modeline
dash integrate for emacs to query program language api keybinding - C-c d
live web development with Emacs
- M-x run-skewer to attach a browser to Emacs
- From a js2-mode buffer with skewer-mode minor mode enabled, send forms to the browser to evaluate
- js evaluating expressions
- C-x C-e: Evaluate the form before the point and display the result in the minibuffer. If given a prefix argument, insert the result into the current buffer.
- C-M-x: Evaluate the top-level form around the point.
- C-c C-k: Load the current buffer.
- C-c C-z: Select the REPL buffer.
- C-x C-e: Load the declaration at the point.
- C-M-x: Load the entire rule around the point.
- C-c C-k: Load the current buffer as a stylesheet.
- C-M-x: Load the HTML tag immediately around the point.
Navigate by char
M-m jump-char-farword <char> move to the next match in the current direction. ; next match forward (towards end of buffer) , next match backward (towards beginning of buffer) C-c C-c invoke `ace-jump-mode’ if available
help you to move the cursor within Emacs,ou can move your cursor to ANY position ( across window and frame ) in emacs by using only 3 times key press.
Wrap Region is a minor mode for Emacs that wraps a region with punctuations.. For “tagged” markup modes, such as HTML and XML, it wraps with tags.
Expand region increases the selected region by semantic units. (global-set-key (kbd “C-=”) ‘er/expand-region)
(global-set-key (kbd “C-S-c C-S-c”) ‘mc/edit-lines) (global-set-key (kbd “C->”) ‘mc/mark-next-like-this) (global-set-key (kbd “C-<”) ‘mc/mark-previous-like-this) (global-set-key (kbd “C-c C-<”) ‘mc/mark-all-like-this)
To get out of multiple-cursors-mode, press <return> or C-g.
- * maxframe
instead of buildin toogle-frame-fullscreen
Fuzzy matching for Emacs … a la Sublime Text.
Projectile is a project interaction library for Emacs. Its goal is to provide a nice set of features operating on a project level without introducing external dependencies
C-c p f (command-p) projectile-find-file C-c p s (command-b) projectile-switch-project
- rainbow-mode Colorize color names in buffers
highlights parentheses, brackets, and braces according to their depth. Each successive level is highlighted in a different color.
buildin highlight symbol C-x w . , M-s h . idle-highlight-mode sets an idle timer that highlights all occurences in the buffer of the word under the point.
navigation: placing the cursor on foo, bar or baz and executing ac-js2-jump-to-definition or M-. will take you straight to their respective definitions. Executing M-, will jump you back to where you were.
ac-js2-expand-function that will expand a function’s parameters bound to C-c C-c. Expansion will only work if the cursor is after the function.
I mainly use org as a note tools, so have many specticular configuration to org, such as customize tags, default templates…