Emacs config utilizing prelude as a base
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

607 lines
21 KiB

13 years ago
14 years ago
14 years ago
  1. Emacs Prelude
  2. =============
  3. Prelude is an Emacs distribution that aims to enhance the default
  4. Emacs experience. Prelude alters a lot of the default settings,
  5. bundles a plethora of additional packages and adds its own core
  6. library to the mix. The final product offers an easy to use Emacs
  7. configuration for Emacs newcomers and lots of additional power for
  8. Emacs power users.
  9. Prelude is compatible **ONLY with GNU Emacs 24.x**. In general you're
  10. advised to always run Prelude with the latest Emacs - currently
  11. **24.3**.
  12. **Table of Contents**
  13. - [Fast Forward](#fast-forward)
  14. - [Installing Emacs 24](#installing-emacs-24)
  15. - [Installation](#installation)
  16. - [Automated](#automated)
  17. - [Via Curl](#via-curl)
  18. - [Via Wget](#via-wget)
  19. - [Manual](#manual)
  20. - [Updating Prelude](#updating-prelude)
  21. - [Manual update](#manual-update)
  22. - [Update all bundled packages](#update-all-bundled-packages)
  23. - [Update Prelude's code](#update-preludes-code)
  24. - [Restart Prelude](#restart-prelude)
  25. - [Automatic update](#automatic-update)
  26. - [Enabling additional modules](#enabling-additional-modules)
  27. - [Running](#running)
  28. - [Getting to know Prelude](#getting-to-know-prelude)
  29. - [Keymap](#keymap)
  30. - [Global](#global)
  31. - [Prelude Mode](#prelude-mode)
  32. - [OSX modifier keys](#osx-modifier-keys)
  33. - [Projectile](#projectile)
  34. - [Key-chords](#key-chords)
  35. - [Disabling key-chords](#disabling-key-chords)
  36. - [Automatic package installation](#automatic-package-installation)
  37. - [Color Themes](#color-themes)
  38. - [Personalizing](#personalizing)
  39. - [Disabling whitespace-mode](#disabling-whitespace-mode)
  40. - [Disable flyspell-mode](#disable-flyspell-mode)
  41. - [Caveats & Pitfalls](#caveats--pitfalls)
  42. - [Updating bundled packages](#updating-bundled-packages)
  43. - [Problems with flyspell-mode](#problems-with-flyspell-mode)
  44. - [Ugly colors in the terminal Emacs version](#ugly-colors-in-the-terminal-emacs-version)
  45. - [MELPA error on initial startup](#melpa-error-on-initial-startup)
  46. - [No arrow navigation in editor buffers](#no-arrow-navigation-in-editor-buffers)
  47. - [Customized C-a behavior](#customized-c-a-behavior)
  48. - [Poor ido matching performance on large datasets](#poor-ido-matching-performance-on-large-datasets)
  49. - [Windows compatibility](#windows-compatibility)
  50. - [Share the knowledge](#share-the-knowledge)
  51. - [Known issues](#known-issues)
  52. - [Support](#support)
  53. - [Contributors](#contributors)
  54. - [Bugs & Improvements](#bugs--improvements)
  55. ## Fast Forward
  56. Assuming you're using an Unix-like OS (`*BSD`, `GNU/Linux`, `OS X`, `Solaris`,
  57. etc), you already have Emacs 24 installed, as well as `git` & `curl` you
  58. can skip the whole manual and just type in your favorite shell the
  59. following command:
  60. ```bash
  61. curl -L http://git.io/epre | sh
  62. ```
  63. You can now power up your Emacs, sit back and enjoy Prelude,
  64. forgetting about the rest of this manual.
  65. There are two environment variables you can use to control the
  66. source repository and the installation directory. To change the
  67. installation directory:
  68. ```bash
  69. export PRELUDE_INSTALL_DIR="$HOME/.emacs.d" && curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  70. ```
  71. To change the source repository:
  72. ```bash
  73. export PRELUDE_URL="https://github.com/yourname/prelude.git" && curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  74. ```
  75. Note that the installer will back up any existing `.emacs` file or
  76. `.emacs.d` since it will unpack Prelude's code in `.emacs.d`. If
  77. you're doing a manual install make sure you don't have a `.emacs` file
  78. or back up your existing `.emacs.d` directory manually.
  79. Don't forget to adjust your `prelude-modules.el` file once the installation is done.
  80. By default most of the modules that ship with Prelude are not loaded.
  81. ## Installing Emacs 24
  82. Obviously to use the Emacs Prelude you have to install Emacs 24
  83. first. Have a look at the [WikEmacs articles on installing Emacs](http://wikemacs.org/wiki/Installing_Emacs).
  84. ## Installation
  85. ### Automated
  86. You can install **Emacs Prelude** via the command line with either `curl` or
  87. `wget`. Naturally `git` is also required.
  88. #### Via Curl
  89. If you're using `curl` type the following command:
  90. ```bash
  91. curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  92. ```
  93. #### Via Wget
  94. If you're using `wget` type:
  95. ```bash
  96. wget --no-check-certificate https://github.com/bbatsov/prelude/raw/master/utils/installer.sh -O - | sh
  97. ```
  98. ### Manual
  99. ```bash
  100. git clone git://github.com/bbatsov/prelude.git path/to/local/repo
  101. ln -s path/to/local/repo ~/.emacs.d
  102. cd ~/.emacs.d
  103. ```
  104. You'd do well to replace `~/.emacs.d` with the value of
  105. `user-emacs-directory` for your OS. You can check the value by doing
  106. `C-h v user-emacs-directory` inside Emacs.
  107. ## Updating Prelude
  108. ### Manual update
  109. The update procedure is fairly straightforward and consists of 3 steps:
  110. #### Update all bundled packages
  111. Just run <kbd>M-x package-list-packages RET U x</kbd>.
  112. #### Update Prelude's code
  113. ```bash
  114. cd path/to/prelude/installation
  115. git pull
  116. ```
  117. The `path/to/prelude/installation` is usually `~/.emacs.d` (at least
  118. on Unix systems).
  119. #### Restart Prelude
  120. It's generally a good idea to stop Emacs after you do the update. The
  121. next time Prelude starts it will install any new dependencies (if
  122. there are such).
  123. ### Automatic update
  124. Simply run <kbd>M-x prelude-update</kbd> from Emacs itself and restart Emacs afterwards.
  125. ## Enabling additional modules
  126. By default most of the modules that ship with Prelude are not loaded. For more information on the functionality provided by these modules visit the [docs](modules/doc/README.md).
  127. ```lisp
  128. ;;; Uncomment the modules you'd like to use and restart Prelude afterwards
  129. (require 'prelude-c)
  130. ;; (require 'prelude-clojure)
  131. ;; (require 'prelude-coffee)
  132. ;; (require 'prelude-common-lisp)
  133. ;; (require 'prelude-css)
  134. (require 'prelude-emacs-lisp)
  135. (require 'prelude-erc)
  136. ;; (require 'prelude-erlang)
  137. ;; (require 'prelude-haskell)
  138. (require 'prelude-js)
  139. ;; (require 'prelude-latex)
  140. (require 'prelude-lisp)
  141. ;; (require 'prelude-markdown)
  142. ;; (require 'prelude-mediawiki)
  143. (require 'prelude-org)
  144. (require 'prelude-perl)
  145. ;; (require 'prelude-python)
  146. ;; (require 'prelude-ruby)
  147. ;; (require 'prelude-scala)
  148. (require 'prelude-scheme)
  149. ;; (require 'prelude-scss)
  150. ;; (require 'prelude-web)
  151. (require 'prelude-xml)
  152. ```
  153. You'll need to adjust your `prelude-modules.el` file once the
  154. installation is done. If you are doing a manual install then you first
  155. need to copy the `prelude-modules.el` available in the sample
  156. directory to the root of `path/to/prelude/installation` and then
  157. adjust that one.
  158. After you've uncommented a module you should either restart Emacs or evaluate the module
  159. `require` expression with <kbd>C-x C-e</kbd>.
  160. ## Running
  161. Nothing fancy here. Just start Emacs as usual. Personally I run Emacs
  162. in daemon mode:
  163. ```bash
  164. emacs --daemon
  165. ```
  166. Afterwards I connect to the server with either a terminal or a GUI
  167. client like this:
  168. ```bash
  169. emacsclient -t
  170. emacsclient -c
  171. ```
  172. You'd probably do well to put a few aliases in your `.zshrc` (or
  173. `.bashrc`):
  174. ```bash
  175. alias e=emacsclient -t
  176. alias ec=emacsclient -c
  177. alias vim=emacsclient -t
  178. alias vi=emacsclient -t
  179. ```
  180. The last two aliases are helpful if you're used to editing files from
  181. the command line using `vi(m)`.
  182. ## Getting to know Prelude
  183. Certainly the best way to understand how Prelude enhances the default
  184. Emacs experience is to peruse Prelude's source code (which is
  185. obviously written in Emacs Lisp). Understanding the code is not
  186. necessary of course. Prelude includes a `prelude-mode` minor Emacs mode
  187. which collects some of the additional functionality added by
  188. Prelude. It also adds an additional keymap that binds many of those
  189. extensions to keybindings.
  190. ### Keymap
  191. #### Global
  192. Keybinding | Description
  193. -------------------|------------------------------------------------------------
  194. <kbd>C-M-h</kbd> | Kill the previous word(`backward-kill-word`). (as in Bash/Zsh)
  195. <kbd>C-x \\</kbd> | `align-regexp`
  196. <kbd>C-+</kbd> | Increase font size(`text-scale-increase`).
  197. <kbd>C--</kbd> | Decrease font size(`text-scale-decrease`).
  198. <kbd>C-x O</kbd> | Go back to previous window (the inverse of `other-window` (`C-x o`)).
  199. <kbd>C-^</kbd> | Join two lines into one(`prelude-top-join-line`).
  200. <kbd>C-x p</kbd> | Start `proced` (manage processes from Emacs; works only in Linux).
  201. <kbd>C-x m</kbd> | Start `eshell`.
  202. <kbd>C-x M-m</kbd> | Start your default shell.
  203. <kbd>C-x C-m</kbd> | Alias for `M-x`.
  204. <kbd>C-h A</kbd> | Run `apropos` (search in all Emacs symbols).
  205. <kbd>M-/</kbd> | Run `hippie-expand` (a replacement for the default `dabbrev-expand`).
  206. <kbd>C-x C-b</kbd> | Open `ibuffer` (a replacement for the default `buffer-list`).
  207. <kbd>F11</kbd> | Make the window full screen.
  208. <kbd>F12</kbd> | Toggle the Emacs menu bar.
  209. <kbd>C-x g</kbd> | Open Magit's status buffer.
  210. <kbd>C-=</kbd> | Run `expand-region` (incremental text selection).
  211. <kbd>C-a</kbd> | Run `prelude-move-beginning-of-line`. Read [this](http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/) for details.
  212. #### Prelude Mode
  213. Keybinding | Description
  214. -------------------|------------------------------------------------------------
  215. <kbd>C-c o</kbd> | Open the currently visited file with an external program.
  216. <kbd>C-c i</kbd> | Search for a symbol, only for buffers that contain code
  217. <kbd>C-c g</kbd> | Search in Google for the thing under point (or an interactive query).
  218. <kbd>C-c G</kbd> | Search in GitHub for the thing under point (or an interactive query).
  219. <kbd>C-c y</kbd> | Search in YouTube for the thing under point (or an interactive query).
  220. <kbd>C-S-RET</kbd> or <kbd>Super-o</kbd> | Insert an empty line above the current line and indent it properly.
  221. <kbd>S-RET</kbd> or <kbd>M-o</kbd> | Insert an empty line and indent it properly (as in most IDEs).
  222. <kbd>C-S-up</kbd> or <kbd>M-S-up</kbd> | Move the current line or region up.
  223. <kbd>C-S-down</kbd> or <kbd>M-S-down</kbd>| Move the current line or region down.
  224. <kbd>C-c n</kbd> | Fix indentation in buffer and strip whitespace.
  225. <kbd>C-c f</kbd> | Open recently visited file.
  226. <kbd>C-M-\\</kbd> | Indent region (if selected) or the entire buffer.
  227. <kbd>C-c u</kbd> | Open URL in your default browser.
  228. <kbd>C-c e</kbd> | Eval a bit of Emacs Lisp code and replace it with its result.
  229. <kbd>C-c s</kbd> | Swap two active windows.
  230. <kbd>C-c d</kbd> | Duplicate the current line (or region).
  231. <kbd>C-c M-d</kbd> | Duplicate and comment the current line (or region).
  232. <kbd>C-c r</kbd> | Rename the currently visited file and buffer.
  233. <kbd>C-c t</kbd> | Open a terminal emulator (`ansi-term`).
  234. <kbd>C-c k</kbd> | Kill all open buffers except the one you're currently in.
  235. <kbd>C-c h</kbd> | Open Helm (a useful means of navigating your buffers and project files).
  236. <kbd>C-c +</kbd> | Increment integer at point.
  237. <kbd>C-c -</kbd> | Decrement integer at point.
  238. <kbd>Super-r</kbd> | Recent files
  239. <kbd>Super-x</kbd> | Expand region
  240. <kbd>Super-j</kbd> | Join lines
  241. <kbd>Super-k</kbd> | Kill whole line
  242. <kbd>Super-m m</kbd> | Magit status
  243. <kbd>Super-m l</kbd> | Magit log
  244. <kbd>Super-m f</kbd> | Magit file log
  245. <kbd>Super-m b</kbd> | Magit blame mode
  246. #### OSX modifier keys
  247. Prelude does not mess by default with the standard mapping of `Command` (to `Super`) and `Option` (to `Meta`).
  248. If you want to swap them add this to your personal config:
  249. ```lisp
  250. (setq mac-command-modifier 'meta)
  251. (setq mac-option-modifier 'super)
  252. ```
  253. You can also temporarily swap them with `C-c w` (`M-x prelude-swap-meta-and-super`).
  254. #### Projectile
  255. Here's a list of functionality provided by [Projectile](https://github.com/bbatsov/projectile):
  256. Keybinding | Description
  257. -------------------|------------------------------------------------------------
  258. <kbd>C-c p f</kbd> | Display a list of all files in the project. With a prefix argument it will clear the cache first.
  259. <kbd>C-c p d</kbd> | Display a list of all directories in the project. With a prefix argument it will clear the cache first.
  260. <kbd>C-c p T</kbd> | Display a list of all test files(specs, features, etc) in the project.
  261. <kbd>C-c p g</kbd> | Run grep on the files in the project.
  262. <kbd>C-c p b</kbd> | Display a list of all project buffers currently open.
  263. <kbd>C-c p o</kbd> | Runs `multi-occur` on all project buffers currently open.
  264. <kbd>C-c p r</kbd> | Runs interactive query-replace on all files in the projects.
  265. <kbd>C-c p i</kbd> | Invalidates the project cache (if existing).
  266. <kbd>C-c p R</kbd> | Regenerates the projects `TAGS` file.
  267. <kbd>C-c p k</kbd> | Kills all project buffers.
  268. <kbd>C-c p D</kbd> | Opens the root of the project in `dired`.
  269. <kbd>C-c p e</kbd> | Shows a list of recently visited project files.
  270. <kbd>C-c p a</kbd> | Runs `ack` on the project. Requires the presence of `ack-and-a-half`.
  271. <kbd>C-c p c</kbd> | Runs a standard compilation command for your type of project.
  272. <kbd>C-c p p</kbd> | Runs a standard test command for your type of project.
  273. <kbd>C-c p z</kbd> | Adds the currently visited to the cache.
  274. <kbd>C-c p s</kbd> | Display a list of known projects you can switch to.
  275. Prelude adds some extra keybindings:
  276. Keybinding | Command
  277. -------------------|------------------------------------------------------------
  278. <kbd>Super-f</kbd> | Find file in project
  279. <kbd>Super-d</kbd> | Find directory in project
  280. <kbd>Super-g</kbd> | Run grep on project
  281. <kbd>Super-p</kbd> | Switch projects
  282. If you ever forget any of Projectile's keybindings just do a:
  283. <kbd>C-c p C-h</kbd>
  284. #### Key-chords
  285. Keybinding | Description
  286. -------------------|----------------------------------------------
  287. <kbd>jj</kbd> | Jump to the beginning of a word(`ace-jump-word-mode`)
  288. <kbd>jk</kbd> | Jump to a character(`ace-jump-char-mode`)
  289. <kbd>jl</kbd> | Jump to the beginning of a line(`ace-jump-line-mode`)
  290. <kbd>JJ</kbd> | Jump back to previous buffer(`prelude-switch-to-previous-buffer`)
  291. <kbd>uu</kbd> | View edits as a tree(`undo-tree-visualize`)
  292. ##### Disabling key-chords
  293. In some cases you may not want to have a key-chord that is defined by prelude,
  294. in which case you can disable the binding in your `personal.el` file by setting
  295. its command to `nil`. For example, to disable the `jj` key-chord add the
  296. following line:
  297. ```lisp
  298. (key-chord-define-global "jj" nil)
  299. ```
  300. If you're an `evil-mode` user you'll probably do well to disable `key-chord-mode` altogether:
  301. ```lisp
  302. (key-chord-mode -1)
  303. ```
  304. ## Automatic package installation
  305. The default Prelude installation comes with a bare minimum of
  306. functionality. It will however install add-ons for various programming
  307. languages and frameworks on demand. For instance - if you try to open
  308. a `.clj` file `clojure-mode`, `nrepl.el` and prelude's enhanced Lisp
  309. configuration will be installed automatically for you.
  310. You can, of course, install anything you wish manually as well.
  311. ### Color Themes
  312. Emacs 24 ships with a new theming facility that effectively renders
  313. the old color-theme package obsolete. Emacs 24 provides a dozen of
  314. built-in themes you can use out-of-the-box by invoking the `M-x
  315. load-theme` command.
  316. [Zenburn](https://github.com/bbatsov/zenburn-emacs) is the default color theme in Prelude, but you can change it
  317. at your discretion. Why Zenburn? I (and lots of hackers around the
  318. world) find it pretty neat for some reason. Personally I find the
  319. default theme pretty tiresome for the eyes, that's why I took that
  320. "controversial" decision to replace it. You can, of course, easily go
  321. back to the default (or select another theme entirely).
  322. To disable Zenburn just put in your personal config the following
  323. line:
  324. ```lisp
  325. (disable-theme 'zenburn)
  326. ```
  327. Or you can use another theme altogether by adding something like:
  328. ```lisp
  329. (load-theme 'solarized-dark t)
  330. ```
  331. **P.S.** Solarized is not available by default - you'll have to
  332. install it from MELPA first (`M-x package-install RET
  333. solarized-theme`).
  334. ### Personalizing
  335. Fork the official Prelude repo and add your own touch to it. You're advised to avoid changing stuff outside of the
  336. personal folder to avoid having to deal with git merge conflicts in the future.
  337. If you'd like to add some auto installation of packages in your
  338. personal config use the following code:
  339. ```lisp
  340. (prelude-require-packages '(some-package some-other-package))
  341. ```
  342. If you require just a single package you can also use:
  343. ```lisp
  344. (prelude-require-package 'some-package)
  345. ```
  346. #### Disabling whitespace-mode
  347. Although `whitespace-mode` is awesome some people might find it too
  348. intrusive. You can disable it in your
  349. personal config with the following bit of code:
  350. ```lisp
  351. (setq prelude-whitespace nil)
  352. ```
  353. If you like `whitespace-mode` but prefer it to not automatically
  354. cleanup your file on save, you can disable that behavior by setting
  355. prelude-clean-whitespace-on-save to nil in your config file with:
  356. ```lisp
  357. (setq prelude-clean-whitespace-on-save nil)
  358. ```
  359. The prelude-clean-whitespace-on-save setting can also be set on a
  360. per-file or directory basis by using a file variable or a
  361. .dir-locals.el file.
  362. #### Disable flyspell-mode
  363. If you're not fond of spellchecking on the fly:
  364. ```lisp
  365. (setq prelude-flyspell nil)
  366. ```
  367. ## Caveats & Pitfalls
  368. ### Updating bundled packages
  369. Generally it's a good idea to do a package update before running
  370. updating Prelude, since the latest Prelude code might depend on newer
  371. versions of the bundled packages than you would currently have
  372. installed.
  373. If you're doing manual Prelude updates you should always do a package update first.
  374. `M-x package-list-packages RET U x`
  375. That's not necessary if you're using `M-x prelude-update`, since it
  376. will automatically update the installed packages.
  377. ### Problems with flyspell-mode
  378. Prelude makes heavy use of the flyspell-mode package for spell
  379. checking of various things. The proper operation of flyspell depends
  380. on the presence of the `aspell` program and an `en` dictionary on your
  381. system. You can install `aspell` and the dictionary on OS X with
  382. `homebrew` like this:
  383. ```bash
  384. brew install aspell --with-lang=en
  385. ```
  386. On Linux distros - just use your distro's package manager.
  387. ### Ugly colors in the terminal Emacs version
  388. If your Emacs looks considerably uglier in a terminal (compared to the
  389. GUI version) try adding this to your `.bashrc` or `.zshrc`:
  390. ```bash
  391. export TERM=xterm-256color
  392. ```
  393. Source the `.bashrc` file and start Emacs again.
  394. ### MELPA error on initial startup
  395. If you get some http connection error related to the MELPA repo
  396. just do a manual `M-x package-refresh-contents` and restart Emacs
  397. afterwards.
  398. ### No arrow navigation in editor buffers
  399. This is not a bug - it's a feature! I firmly believe that the one true
  400. way to use Emacs is by using it the way it was intended to be used (as
  401. far as navigation is concerned at least). That's why I've disabled all
  402. movement commands with arrows (and keys like page up, page down, etc) - to prevent you from being tempted to
  403. use them.
  404. If you'd still like to use the arrow keys just invoke `M-x
  405. guru-mode` to enable them for the duration of your
  406. current Emacs session or add the following snippet to your
  407. personal Emacs customization to enable them permanently:
  408. ```lisp
  409. (setq prelude-guru nil)
  410. ```
  411. ### Customized C-a behavior
  412. Prelude overrides `C-a` to behave as described
  413. [here](http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/). If
  414. you don't like that simply add this to your personal config:
  415. ```lisp
  416. (global-set-key [remap move-beginning-of-line]
  417. 'move-beginning-of-line)
  418. ```
  419. ### Poor ido matching performance on large datasets
  420. Prelude swaps the default `ido` flex matching with the more powerful
  421. [ido-flx](https://github.com/lewang/flx).
  422. The sorting algorithm `flx` uses is more complex, but yields better results.
  423. On slower machines, it may be necessary to lower `flx-ido-threshhold` to
  424. ensure a smooth experience.
  425. ```lisp
  426. (setq flx-ido-threshhold 1000)
  427. ```
  428. You can always disable the improved sorting algorithm all together like this:
  429. ```lisp
  430. (flx-ido-mode -1)
  431. ```
  432. ### Windows compatibility
  433. While everything in Prelude should work fine in Windows, I test it only
  434. with Linux & OSX, so there are Windows related problems from time to
  435. time. This situation will probably improve over time.
  436. ## Share the knowledge
  437. [WikEmacs](http://wikemacs.org) collects useful resources for working
  438. with GNU Emacs. Please, take the time to peruse and improve them as
  439. you accumulate knowledge about Emacs. Prelude makes this especially
  440. easy, since it bundles
  441. [MediaWiki support](http://wikemacs.org/wiki/Mediawiki.el) + the
  442. settings required to access WikEmacs right away.
  443. ## Known issues
  444. Check out the project's
  445. [issue list](https://github.com/bbatsov/prelude/issues?sort=created&direction=desc&state=open)
  446. a list of unresolved issues. By the way - feel free to fix any of them
  447. and send me a pull request. :-)
  448. ## Support
  449. Support is available via the Prelude Google Group <emacs-prelude@googlegroups.com>.
  450. ## Contributors
  451. Here's a [list](https://github.com/bbatsov/prelude/contributors) of all the people who have contributed to the
  452. development of Emacs Prelude.
  453. ## Bugs & Improvements
  454. Bug reports and suggestions for improvements are always
  455. welcome. GitHub pull requests are even better! :-)
  456. Cheers,<br/>
  457. [Bozhidar](https://twitter.com/bbatsov)