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.

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