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.

336 lines
11 KiB

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