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.

428 lines
14 KiB

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