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.

343 lines
11 KiB

14 years ago
14 years ago
14 years ago
14 years ago
  1. Emacs Prelude
  2. =============
  3. Emacs is probably the best text editor in the world. However, the
  4. process of coming up with a useful Emacs configuration is long and
  5. difficult. It's this process that separates you from truly taking
  6. advantage of Emacs's power. I like to refer to this process as the
  7. **Prelude**. **Emacs Prelude** has the goal to ease the initial Emacs
  8. setup process and to provide you with a much more powerful and
  9. productive experience than the one you get out of the box. By using
  10. **Emacs Prelude** you're basically getting a *"Get me out of the
  11. Prelude, I just want to use Emacs"* card.
  12. Emacs Prelude is compatible **ONLY with GNU Emacs 24.x**.
  13. ## Fast Forward
  14. Assuming you're using an Unix-like OS (`*BSD`, `GNU/Linux`, `OS X`, `Solaris`,
  15. etc), you already have Emacs 24 installed, as well as `git` & `curl` you
  16. can skip the whole manual and just type in your favorite shell the
  17. following command:
  18. ```bash
  19. $ curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  20. ```
  21. You can now power up your Emacs, sit back and enjoy Prelude,
  22. forgetting about the rest of this manual.
  23. There are two environment variables you can use to control the
  24. source repository and the installation directory. To change the
  25. installation directory:
  26. ```bash
  27. $ export PRELUDE_INSTALL_DIR="$HOME/.emacs.d" && curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  28. ```
  29. To change the source repository:
  30. ```bash
  31. $ export PRELUDE_URL="https://github.com/yourname/prelude.git" && curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  32. ```
  33. Note that the installer will back up any existing `.emacs` file or
  34. `.emacs.d` since it will unpack Prelude's code in `.emacs.d`. If
  35. you're doing a manual install make sure you don't have a `.emacs` file
  36. or back up your existing `.emacs.d` directory manually.
  37. ## More goodies
  38. The [Prelude Modules](https://github.com/bbatsov/prelude-modules)
  39. project contains a lot of additional packages for Prelude
  40. (install-able via the `package-list-packages` command) - enhanced programming
  41. mode configs, latex config, erc config, etc.
  42. ## Installing Emacs 24
  43. Obviously to use the Emacs Prelude you have to install Emacs 24
  44. first. Have a look at the [WikEmacs articles on installing Emacs](http://wikemacs.org/wiki/Installing_Emacs).
  45. ## Installation
  46. ### Automated
  47. You can install **Emacs Prelude** via the command line with either `curl` or
  48. `wget`. Naturally `git` is also required.
  49. #### Via Curl
  50. If you're using `curl` type the following command:
  51. ```bash
  52. $ curl -L https://github.com/bbatsov/prelude/raw/master/utils/installer.sh | sh
  53. ```
  54. #### Via Wget
  55. If you're using `wget` type:
  56. ```bash
  57. $ wget --no-check-certificate https://github.com/bbatsov/prelude/raw/master/utils/installer.sh -O - | sh
  58. ```
  59. ### Manual
  60. ```bash
  61. $ git clone git://github.com/bbatsov/prelude.git path/to/local/repo
  62. $ ln -s path/to/local/repo ~/.emacs.d
  63. $ cd ~/emacs.d
  64. ```
  65. You'd do well to replace `~/.emacs.d` with the value of
  66. `user-emacs-directory` for your OS. You can check the value by doing
  67. `C-h v user-emacs-directory` inside Emacs.
  68. ## Running
  69. Nothing fancy here. Just start Emacs as usual. Personally I run Emacs
  70. in daemon mode:
  71. ```bash
  72. $ emacs --daemon
  73. ```
  74. Afterwards I connect to the server with either a terminal or a GUI
  75. client like this:
  76. ```bash
  77. $ emacsclient -t
  78. $ emacsclient -c
  79. ```
  80. You'd probably do well to put a few aliases in your `.zshrc` (or
  81. `.bashrc`):
  82. ```bash
  83. alias e=emacsclient -t
  84. alias ec=emacsclient -c
  85. alias vim=emacsclient -t
  86. alias vi=emacsclient -t
  87. ```
  88. The last two aliases are helpful if you're used to editing files from
  89. the command line using `vi(m)`.
  90. ## Getting to know Prelude
  91. Certainly the best way to understand how Prelude enhances the default
  92. Emacs experience is to peruse Prelude's source code (which is
  93. obviously written in Emacs Lisp). Understanding the code is not
  94. necessary of course. Prelude includes a `prelude-mode` minor Emacs mode
  95. which collects some of the additional functionality added by
  96. Prelude. It also adds an additional keymap that binds many of those
  97. extensions to keybindings.
  98. ### Keymap
  99. #### Global
  100. * `C-M-h` - `backward-kill-word` (as in Bash/Zsh)
  101. * `C-x \` - `align-regexp`
  102. * `C-+` - `text-scale-increase`
  103. * `C--` - `text-scale-decrease`
  104. * `C-x O` - return you to the previous window (the inverse of `other-window` (`C-x o`))
  105. * `C-x ^` - `join-line`
  106. * `C-x p` - `proced` (manage processes form Emacs, works only in Linux)
  107. * `C-x m` - start eshell
  108. * `C-x M-m` - start your default shell
  109. * `C-x C-m` - sames as `M-x`
  110. * `C-h A` - `apropos` (search in all Emacs symbols)
  111. * `M-\` - `hippie-expand` (a replacement for the default `dabbrev-expand`)
  112. * `C-x C-b` - `ibuffer` (a replacement for the default `buffer-list`)
  113. * `F12` - toggle the Emacs menu bar
  114. * `C-x g` - open Magit's status buffer
  115. * `C-=` - `expand-region` (incremental text selection)
  116. #### Prelude Mode
  117. * `C-c o` - open the currently visited file with external program
  118. * `C-c g` - search in Google for the thing under point (or an interactive query)
  119. * `shift+return` - insert an empty line and indent it properly (as in most IDEs)
  120. * `control+shift+up` - move the current line up
  121. * `control+shift+down` - move the current line down
  122. * `C-c n` - fix indentation in buffer and strip whitespace
  123. * `C-c f` - open recently visitted file
  124. * `C-M-\` - indent region (if selected) or the entire buffer
  125. * `C-c u` - open URL in your default browser
  126. * `C-c e` - eval a bit of Emacs Lisp code and replace it with its result
  127. * `C-c s` - swap two active windows
  128. * `C-c d` - duplicate the current line (or region)
  129. * `C-c r` - rename the currently visited file and buffer
  130. * `C-c t` - open a terminal emulator (`ansi-term`)
  131. * `C-c k` - kill all open buffers except the one you're currently in
  132. * `C-c h` - open Helm (a useful means of navigating your buffers and project files)
  133. #### Projectile
  134. Here's a list of the interactive Emacs Lisp functions, provided by projectile:
  135. * `projectile-find-file` <kbd>C-c p f</kbd>
  136. * `projectile-grep` <kbd>C-c p g</kbd>
  137. * `projectile-switch-to-buffer` <kbd>C-c p b</kbd>
  138. * `projectile-multi-occur` <kbd>C-c p o</kbd>
  139. * `projectile-replace` <kbd>C-c p r</kbd>
  140. * `projectile-invalidate-cache` <kbd>C-c p i</kbd>
  141. * `projectile-regenerate-tags` <kbd>C-c p t</kbd>
  142. * `projectile-kill-buffers` <kbd>C-c p k</kbd>
  143. * `projectile-dired` <kbd>C-c p d</kbd>
  144. * `projectile-recentf` <kbd>C-c p e</kbd>
  145. * `projectile-ack` <kbd>C-c p a</kbd>
  146. * `projectile-compile-project` <kbd>C-c p l</kbd>
  147. * `projectile-test-project` <kbd>C-c p p</kbd>
  148. ### Automatic package installation
  149. The default Prelude installation comes with a bare minimum of
  150. functionality. It will however install add-ons for various programming
  151. languages and frameworks on demand. For instance - if you try to open
  152. a `.clj` file `clojure-mode`, `nrepl.el` and prelude's enhanced Lisp
  153. configuration will be installed automatically for you.
  154. You can, of course, install anything you wish manually as well.
  155. ### Color Themes
  156. Emacs 24 ships with a new theming facility that effectively renders
  157. the old color-theme package obsolete. Emacs 24 provides a dozen of
  158. built-in themes you can use out-of-the-box by invoking the `M-x
  159. load-theme` command.
  160. [Zenburn](https://github.com/bbatsov/zenburn-emacs) is the default color theme in Prelude, but you can change it
  161. at your discretion. Why Zenburn? I (and lots of hackers around the
  162. world) find it pretty neat for some reason. Personally I find the
  163. default theme pretty tiresome for the eyes, that's why I took that
  164. "controversial" decision to replace it. You can, of course, easily go
  165. back to the default (or select another theme entirely).
  166. To disable Zenburn just put in your personal config the following
  167. line:
  168. ```lisp
  169. (disable-theme 'zenburn)
  170. ```
  171. Or you can use another theme altogether by adding something like:
  172. ```lisp
  173. (load-theme 'solarized-dark t)
  174. ```
  175. P.S. Solarized is not available by default - you'll have to install it from MELPA first.
  176. ### Personalizing
  177. Fork the official Prelude repo and add your own touch to it. You're advised to avoid changing stuff outside of the
  178. personal folder to avoid having to deal with git merge conflicts in the future.
  179. #### Disabling whitespace-mode
  180. Although `whitespace-mode` is awesome some people might find it too
  181. intrusive. You can disable it in your
  182. personal config with the following bit of code:
  183. ```lisp
  184. (setq prelude-whitespace nil)
  185. ```
  186. #### Disable flyspell-mode
  187. If you're not fond of spellchecking on the fly:
  188. ```lisp
  189. (setq prelude-flyspell nil)
  190. ```
  191. ## Caveats & Pitfalls
  192. ### Problems with flyspell-mode
  193. Prelude makes heavy use of the flyspell-mode package for spell
  194. checking of various things. The proper operation of flyspell depends
  195. on the presence of the `aspell` program and an `en` dictionary on your
  196. system. You can install `aspell` and the dictionary on OS X with
  197. `homebrew` like this:
  198. ```bash
  199. $ brew install aspell --lang=en
  200. ```
  201. On Linux distros - just use your distro's package manager.
  202. ### Ugly colors in the terminal Emacs version
  203. If your Emacs looks considerably uglier in a terminal (compared to the
  204. GUI version) try adding this to your `.bashrc` or `.zshrc`:
  205. ```bash
  206. $ export TERM=xterm-256color
  207. ```
  208. Source the `.bashrc` file and start Emacs again.
  209. ### MELPA error on initial startup
  210. If you get some http connection error related to the MELPA repo
  211. just do a manual `M-x package-refresh-contents` and restart Emacs
  212. afterwards.
  213. ### No arrow navigation in editor buffers
  214. This is not a bug - it's a feature! I firmly believe that the one true
  215. way to use Emacs is by using it the way it was intended to be used (as
  216. far as navigation is concerned at least). That's why I've disabled all
  217. movement commands with arrows (and keys like page up, page down, etc) - to prevent you from being tempted to
  218. use them.
  219. If you'd still like to use the arrow keys just invoke `M-x
  220. guru-mode` to enable them for the duration of your
  221. current Emacs session or add the following snippet to your
  222. personal Emacs customization to enable them permanently:
  223. ```lisp
  224. (setq prelude-guru nil)
  225. ```
  226. ### Windows compatibility
  227. While everything in Prelude should work fine in Windows, I test it only
  228. with Linux & OSX, so there are Windows related problems from time to
  229. time. This situation will probably improve over time.
  230. ## Share the knowledge
  231. [WikEmacs](http://wikemacs.org) collects useful resources for working
  232. with GNU Emacs. Please, take the time to peruse and improve them as
  233. you accumulate knowledge about Emacs. Prelude makes this especially
  234. easy, since it bundles
  235. [MediaWiki support](http://wikemacs.org/wiki/Mediawiki.el) + the
  236. settings required to access WikEmacs right away.
  237. ## Known issues
  238. Check out the project's
  239. [issue list](https://github.com/bbatsov/prelude/issues?sort=created&direction=desc&state=open)
  240. a list of unresolved issues. By the way - feel free to fix any of them
  241. and send me a pull request. :-)
  242. ## Support
  243. Support is available via the Prelude Google Group <emacs-prelude@googlegroups.com>.
  244. ## Contributors
  245. Here's a [list](https://github.com/bbatsov/prelude/contributors) of all the people who have contributed to the
  246. development of Emacs Prelude.
  247. ## Bugs & Improvements
  248. Bug reports and suggestions for improvements are always
  249. welcome. GitHub pull requests are even better! :-)
  250. Cheers,<br/>
  251. Bozhidar