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.

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