diff --git a/core-prelude.el b/core-prelude.el deleted file mode 100644 index a29204c..0000000 --- a/core-prelude.el +++ /dev/null @@ -1 +0,0 @@ -(provide 'core-prelude) diff --git a/init.el b/init.el index 0cbce69..5ba014f 100644 --- a/init.el +++ b/init.el @@ -1,9 +1,55 @@ +;;; init.el --- Emacs Prelude: configuration entry point. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; This file simply sets up the default load path and requires +;; the various modules defined within Emacs Prelude. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + (defvar prelude-dir "~/.emacs.d/") +(defvar vendor-dir (concat prelude-dir "vendor")) (add-to-list 'load-path prelude-dir) -(require 'ui-prelude) -(require 'packages-prelude) -(require 'core-prelude) -(require 'editor-prelude) -(require 'global-keybindings-prelude) +(require 'prelude-ui) +(require 'prelude-packages) +(require 'prelude-core) +(require 'prelude-editor) +(require 'prelude-global-keybindings) + +;; programming & markup languages support +(require 'prelude-c) +(require 'prelude-clojure) +(require 'prelude-common-lisp) +(require 'prelude-emacs-lisp) +(require 'prelude-haskell) +(require 'prelude-ruby) + +;;; init.el ends here diff --git a/packages-prelude.el b/packages-prelude.el deleted file mode 100644 index 9c0daa2..0000000 --- a/packages-prelude.el +++ /dev/null @@ -1,18 +0,0 @@ -(require 'package) -(add-to-list 'package-archives - '("marmalade" . "http://marmalade-repo.org/packages/") t) -(package-initialize) - -(when (not package-archive-contents) - (package-refresh-contents)) - -(defvar prelude-packages '(auctex clojure-mode coffee-mode gist haml-mode - haskell-mode magit markdown-mode paredit - sass-mode yasnippet) - "A list of packages to ensure are installed at launch.") - -(dolist (p prelude-packages) - (when (not (package-installed-p p)) - (package-install p))) - -(provide 'packages-prelude) diff --git a/prelude-c.el b/prelude-c.el new file mode 100644 index 0000000..58c525a --- /dev/null +++ b/prelude-c.el @@ -0,0 +1,45 @@ +;;; prelude-c.el --- Emacs Prelude: cc-mode configuration. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for cc-mode and the modes derived from it. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(defun prelude-c-coding-hook () + (setq c-basic-offset 4) + (prelude-coding-hook)) + +;; this will affect all modes derived from cc-mode, like +;; java-mode, php-mode, etc +(add-hook 'c-mode-common-hook 'prelude-c-coding-hook) + +(provide 'prelude-c) + +;;; prelude-c.el ends here diff --git a/prelude-clojure.el b/prelude-clojure.el new file mode 100644 index 0000000..78d1404 --- /dev/null +++ b/prelude-clojure.el @@ -0,0 +1,46 @@ +;;; prelude-clojure.el --- Emacs Prelude: Clojure programming configuration. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for clojure-mode. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'prelude-lisp) + +;; To start SLIME in your Clojure project: +;; 1. lein plugin install swank-clojure 1.3.1 +;; 2. Invoke M-x clojure-jack-in from a project +(require 'clojure-mode) + +(add-hook 'clojure-mode-hook 'prelude-lisp-coding-hook) + +(provide 'prelude-clojure) + +;;; prelude-clojure.el ends here diff --git a/prelude-common-lisp.el b/prelude-common-lisp.el new file mode 100644 index 0000000..da9411e --- /dev/null +++ b/prelude-common-lisp.el @@ -0,0 +1,94 @@ +;;; prelude-common-lisp.el --- Emacs Prelude: lisp-mode and SLIME config. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Configuration for lisp-mode and SLIME. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'prelude-lisp) + +;; the SBCL configuration file is in Common Lisp +(add-to-list 'auto-mode-alist '("\\.sbclrc$" . lisp-mode)) + +;; Use SLIME from Quicklisp +(defun prelude-load-common-lisp-slime () + (interactive) + ;; Common Lisp support depends on SLIME being installed with Quicklisp + (if (file-exists-p (expand-file-name "~/quicklisp/slime-helper.el")) + (load (expand-file-name "~/quicklisp/slime-helper.el")) + (message "%s" "SLIME is not installed. Use Quicklisp to install it.")) + ) + +;; a list of alternative Common Lisp implementations that can be +;; used with SLIME. Note that their presence render +;; inferior-lisp-program useless. This variable holds a list of +;; programs and if you invoke SLIME with a negative prefix +;; argument, M-- M-x slime, you can select a program from that list. +(setq slime-lisp-implementations + '((ccl ("ccl")) + (clisp ("clisp" "-q")) + (cmucl ("cmucl" "-quiet")) + (sbcl ("sbcl" "--noinform") :coding-system utf-8-unix))) + +;; select the default value from slime-lisp-implementations +(setq slime-default-lisp 'sbcl) + +(add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook) +(add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook) + +;; start slime automatically when we open a lisp file +(defun prelude-start-slime () + (unless (slime-connected-p) + (save-excursion (slime)))) + +(add-hook 'slime-mode-hook 'prelude-start-slime) + +;; Stop SLIME's REPL from grabbing DEL, +;; which is annoying when backspacing over a '(' +(defun prelude-override-slime-repl-bindings-with-paredit () + (define-key slime-repl-mode-map + (read-kbd-macro paredit-backward-delete-key) nil)) + +(add-hook 'slime-repl-mode-hook 'prelude-override-slime-repl-bindings-with-paredit) + +(eval-after-load "slime" + '(progn + (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol + slime-fuzzy-completion-in-place t + slime-enable-evaluate-in-emacs t + slime-autodoc-use-multiline-p t) + + (define-key slime-mode-map (kbd "TAB") 'slime-indent-and-complete-symbol) + (define-key slime-mode-map (kbd "C-c i") 'slime-inspect) + (define-key slime-mode-map (kbd "C-c C-s") 'slime-selector))) + +(provide 'prelude-common-lisp) + +;;; prelude-common-lisp.el ends here diff --git a/prelude-core.el b/prelude-core.el new file mode 100644 index 0000000..ef9f4bb --- /dev/null +++ b/prelude-core.el @@ -0,0 +1,411 @@ +;;; prelude-core.el --- Emacs Prelude: core Prelude defuns. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Here are the definitions of most of the functions added by Prelude. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'cl) +(require 'thingatpt) +(require 'imenu) + +(defun prelude-add-subfolders-to-load-path (parent-dir) + "Adds all first level `parent-dir' subdirs to the +Emacs load path." + (dolist (f (directory-files parent-dir)) + (let ((name (concat parent-dir f))) + (when (and (file-directory-p name) + (not (equal f "..")) + (not (equal f "."))) + (add-to-list 'load-path name))))) + +;; add the first level subfolders automatically +(prelude-add-subfolders-to-load-path prelude-dir) +(prelude-add-subfolders-to-load-path vendor-dir) + +(defun prelude-open-with () + "Simple function that allows us to open the underlying +file of a buffer in an external program." + (interactive) + (when buffer-file-name + (shell-command (concat + (read-shell-command "Open current file with: ") + " " + buffer-file-name)))) + +(defun prelude-buffer-mode (buffer-or-name) + (with-current-buffer buffer-or-name major-mode)) + +(defun prelude-visit-term-buffer () + (interactive) + (if (not (get-buffer "*ansi-term*")) + (ansi-term "/bin/zsh") + (switch-to-buffer "*ansi-term*"))) + +(defun prelude-indent-rigidly-and-copy-to-clipboard (begin end indent) + "Copy the selected code region to the clipboard, indented according +to Markdown blockquote rules." + (let ((buffer (current-buffer))) + (with-temp-buffer + (insert-buffer-substring-no-properties buffer begin end) + (indent-rigidly (point-min) (point-max) indent) + (clipboard-kill-ring-save (point-min) (point-max))))) + +(defun prelude-indent-blockquote-and-copy-to-clipboard (begin end) + "Copy the selected code region to the clipboard, indented according +to markdown blockquote rules (useful to copy snippets to StackOverflow, Assembla, Github." + (interactive "r") + (prelude-indent-rigidly-and-copy-to-clipboard begin end 4)) + +(defun prelude-indent-nested-blockquote-and-copy-to-clipboard (begin end) + "Copy the selected code region to the clipboard, indented according +to markdown blockquote rules. Useful to add snippets under bullet points." + (interactive "r") + (indent-rigidly-and-copy-to-clipboard begin end 6)) + +(defun prelude-insert-empty-line () + "Insert an empty line after the current line and positon +the curson at its beginning, according to the current mode." + (interactive) + (move-end-of-line nil) + (open-line 1) + (next-line 1) + (indent-according-to-mode)) + +;; mimic popular IDEs binding, note that it doesn't work in a terminal session +(global-set-key [(shift return)] 'prelude-insert-empty-line) + +(defun prelude-move-line-up () + "Move up the current line." + (interactive) + (transpose-lines 1) + (previous-line 2)) + +(global-set-key [(control shift up)] 'prelude-move-line-up) + +(defun prelude-move-line-down () + "Move down the current line." + (interactive) + (next-line 1) + (transpose-lines 1) + (previous-line 1)) + +(global-set-key [(control shift down)] 'prelude-move-line-down) + +;; add the ability to copy and cut the current line, without marking it +(defadvice kill-ring-save (before slick-copy activate compile) + "When called interactively with no active region, copy a single line instead." + (interactive + (if mark-active (list (region-beginning) (region-end)) + (message "Copied line") + (list (line-beginning-position) + (line-beginning-position 2))))) + +(defadvice kill-region (before slick-cut activate compile) + "When called interactively with no active region, kill a single line instead." + (interactive + (if mark-active (list (region-beginning) (region-end)) + (list (line-beginning-position) + (line-beginning-position 2))))) + +(defun prelude-indent-buffer () + "Indents the entire buffer." + (interactive) + (indent-region (point-min) (point-max))) + +(defun prelude-indent-region-or-buffer () + "Indents a region if selected, otherwise the whole buffer." + (interactive) + (save-excursion + (if (region-active-p) + (progn + (indent-region (region-beginning) (region-end)) + (message "Indented selected region.")) + (progn + (indent-buffer) + (message "Indented buffer."))))) + +(defun prelude-annotate-todo () + "Put fringe marker on TODO: lines in the curent buffer." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "TODO:" nil t) + (let ((overlay (make-overlay (- (point) 5) (point)))) + (overlay-put overlay + 'before-string + (propertize (format "A") + 'display '(left-fringe right-triangle))))))) + +(defun prelude-copy-file-name-to-clipboard () + "Put the current file name on the clipboard." + (interactive) + (let ((filename (if (equal major-mode 'dired-mode) + default-directory + (buffer-file-name)))) + (when filename + (with-temp-buffer + (insert filename) + (clipboard-kill-region (point-min) (point-max))) + (message filename)))) + +(defun prelude-duplicate-current-line-or-region (arg) + "Duplicates the current line or region ARG times. +If there's no region, the current line will be duplicated. However, if +there's a region, all lines that region covers will be duplicated." + (interactive "p") + (let (beg end (origin (point))) + (if (and mark-active (> (point) (mark))) + (exchange-point-and-mark)) + (setq beg (line-beginning-position)) + (if mark-active + (exchange-point-and-mark)) + (setq end (line-end-position)) + (let ((region (buffer-substring-no-properties beg end))) + (dotimes (i arg) + (goto-char end) + (newline) + (insert region) + (setq end (point))) + (goto-char (+ origin (* (length region) arg) arg))))) + +;; TODO doesn't work with uniquify +(defun prelude-rename-file-and-buffer () + "Renames current buffer and file it is visiting." + (interactive) + (let ((name (buffer-name)) + (filename (buffer-file-name))) + (if (not (and filename (file-exists-p filename))) + (message "Buffer '%s' is not visiting a file!" name) + (let ((new-name (read-file-name "New name: " filename))) + (cond ((get-buffer new-name) + (message "A buffer named '%s' already exists!" new-name)) + (t + (rename-file name new-name 1) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil))))))) + +(defun prelude-delete-file-and-buffer () + "Kills the current buffer and deletes the file it is visiting" + (interactive) + (let ((filename (buffer-file-name))) + (when filename + (delete-file filename) + (message "Deleted file %s" filename))) + (kill-buffer)) + +(defun prelude-view-url () + "Open a new buffer containing the contents of URL." + (interactive) + (let* ((default (thing-at-point-url-at-point)) + (url (read-from-minibuffer "URL: " default))) + (switch-to-buffer (url-retrieve-synchronously url)) + (rename-buffer url t) + ;; TODO: switch to nxml/nxhtml mode + (cond ((search-forward " +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Refinements of the core editing experience in Emacs. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + ;; Emacs users obviously have little need for Command and Option keys, ;; but they do need Meta and Super -(when (string= system-type "darwin") +(when (string= system-type "darwin") (setq mac-command-modifier 'super) (setq mac-option-modifier 'meta)) @@ -10,7 +44,7 @@ ;; delete the selection with a keypress (delete-selection-mode t) ;; highlight when searching and replacing -(setq search-highlight t +(setq search-highlight t query-replace-highlight t) ;; store all backup and autosave files in the tmp dir @@ -61,10 +95,10 @@ ;; time-stamps ;; when there's "Time-stamp: <>" in the first 10 lines of the file -(setq - time-stamp-active t ; do enable time-stamps - time-stamp-line-limit 10 ; check first 10 buffer lines for Time-stamp: <> - time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format +(setq time-stamp-active t + ;; check first 10 buffer lines for Time-stamp: <> + time-stamp-line-limit 10 + time-stamp-format "%04y-%02m-%02d %02H:%02M:%02S (%u)") ; date format (add-hook 'write-file-hooks 'time-stamp) ; update when saving ;; use shift + arrow keys to switch between visible buffers @@ -80,18 +114,6 @@ ;; keep in mind known issues with zsh - see emacs wiki (setq tramp-default-method "ssh") -;; now we can use tramp to open files -;; requiring root access -(defun find-alternative-file-with-sudo () - "Open current buffer as root!" - (interactive) - (when buffer-file-name - (find-alternate-file - sudo/su can be used as well, but they - do not work for me - (concat "/ssh:root@localhost:" - buffer-file-name)))) - ;; ido-mode (ido-mode t) (setq ido-enable-prefix nil @@ -110,19 +132,22 @@ (setq ispell-program-name "aspell" ; use aspell instead of ispell ispell-extra-args '("--sug-mode=ultra")) (autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t) -(add-hook 'message-mode-hook 'turn-on-flyspell) -(add-hook 'text-mode-hook 'turn-on-flyspell) -(defun turn-on-flyspell () +(defun prelude-turn-on-flyspell () "Force flyspell-mode on using a positive argument. For use in hooks." (interactive) (flyspell-mode 1)) +(add-hook 'message-mode-hook 'prelude-turn-on-flyspell) +(add-hook 'text-mode-hook 'prelude-turn-on-flyspell) + ;; enable narrow to region (put 'narrow-to-region 'disabled nil) ;; bookmarks -(setq bookmark-default-file "~/.emacs.d/bookmarks" - bookmark-save-flag 1) +(setq bookmark-default-file "~/.emacs.d/bookmarks" + bookmark-save-flag 1) -(provide 'editor-prelude) +(provide 'prelude-editor) + +;;; prelude-editor.el ends here diff --git a/prelude-emacs-lisp.el b/prelude-emacs-lisp.el new file mode 100644 index 0000000..2052c27 --- /dev/null +++ b/prelude-emacs-lisp.el @@ -0,0 +1,58 @@ +;;; prelude-emacs-lisp.el --- Emacs Prelude: Nice config for Elisp programming. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Nice config for Elisp Programming. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + + +(require 'prelude-lisp) + +(add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) +(add-hook 'emacs-lisp-mode-hook 'prelude-remove-elc-on-save) + +(add-hook 'emacs-lisp-mode-hook 'prelude-lisp-coding-hook) + +(add-hook 'ielm-mode-hook 'prelude-interactive-lisp-coding-hook) +(add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) + +(defun prelude-remove-elc-on-save () + "If you're saving an elisp file, likely the .elc is no longer valid." + (make-local-variable 'after-save-hook) + (add-hook 'after-save-hook + (lambda () + (if (file-exists-p (concat buffer-file-name "c")) + (delete-file (concat buffer-file-name "c")))))) + +(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point) + +(provide 'prelude-emacs-lisp) + +;;; prelude-emacs-lisp.el ends here diff --git a/global-keybindings-prelude.el b/prelude-global-keybindings.el similarity index 63% rename from global-keybindings-prelude.el rename to prelude-global-keybindings.el index c06ac72..c7e0550 100644 --- a/global-keybindings-prelude.el +++ b/prelude-global-keybindings.el @@ -1,3 +1,37 @@ +;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Lots of useful keybindings. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + ;; You know, like Readline. (global-set-key (kbd "C-M-h") 'backward-kill-word) @@ -12,12 +46,12 @@ (define-key global-map (kbd "C--") 'text-scale-decrease) ;; Jump to a definition in the current file. (This is awesome.) -(global-set-key (kbd "M-i") 'ido-goto-symbol) +(global-set-key (kbd "M-i") 'prelude-ido-goto-symbol) ;; File finding (global-set-key (kbd "C-x M-f") 'ido-find-file-other-window) (global-set-key (kbd "C-x C-M-f") 'projectile-jump-to-project-file) -(global-set-key (kbd "C-x f") 'recentf-ido-find-file) +(global-set-key (kbd "C-x f") 'prelude-recentf-ido-find-file) (global-set-key (kbd "C-c r") 'bury-buffer) (global-set-key (kbd "M-`") 'file-cache-minibuffer-complete) @@ -46,13 +80,13 @@ (global-set-key (kbd "C-x C-m") 'execute-extended-command) ;; Fetch the contents at a URL, display it raw. -(global-set-key (kbd "C-x C-h") 'view-url) +(global-set-key (kbd "C-x C-h") 'prelude-view-url) ;; A complementary binding to the apropos-command(C-h a) (global-set-key (kbd "C-h A") 'apropos) ;; Should be able to eval-and-replace anywhere. -(global-set-key (kbd "C-c e") 'eval-and-replace) +(global-set-key (kbd "C-c e") 'prelude-eval-and-replace) ;; Magit rules! (global-set-key (kbd "C-x g") 'magit-status) @@ -80,33 +114,30 @@ ;; replace buffer-menu with ibuffer (global-set-key (kbd "C-x C-b") 'ibuffer) -;; interactive text replacement -(global-set-key (kbd "C-c C-r") 'iedit-mode) - ;; swap windows -(global-set-key (kbd "C-c s") 'swap-windows) +(global-set-key (kbd "C-c s") 'prelude-swap-windows) ;; duplicate the current line or region -(global-set-key (kbd "C-c d") 'duplicate-current-line-or-region) +(global-set-key (kbd "C-c d") 'prelude-duplicate-current-line-or-region) ;; rename buffer & visited file -(global-set-key (kbd "C-c r") 'rename-file-and-buffer) +(global-set-key (kbd "C-c r") 'prelude-rename-file-and-buffer) ;; open an ansi-term buffer -(global-set-key (kbd "C-x t") 'visit-term-buffer) +(global-set-key (kbd "C-x t") 'prelude-visit-term-buffer) ;; toggle input method -(global-set-key (kbd "C-\\") 'toggle-bulgarian-input-method) +(global-set-key (kbd "C-\\") 'prelude-toggle-bulgarian-input-method) ;; search with google -(global-set-key (kbd "C-c g") 'google) +(global-set-key (kbd "C-c g") 'prelude-google) ;; toggle menu-bar visibility (global-set-key (kbd "") 'menu-bar-mode) ;; real Emacs hackers don't use the arrow keys -(global-set-key (kbd "") (lambda () - (interactive) +(global-set-key (kbd "") (lambda () + (interactive) (message "Arrow key navigation is disabled. Use C-p instead."))) (global-set-key (kbd "") (lambda () (interactive) @@ -114,8 +145,10 @@ (global-set-key (kbd "") (lambda () (interactive) (message "Arrow key navigation is disabled. Use C-b instead."))) -(global-set-key (kbd "") (lambda () +(global-set-key (kbd "") (lambda () (interactive) (message "Arrow key navigation is disabled. Use C-f instead."))) -(provide 'global-keybindings-prelude) +(provide 'prelude-global-keybindings) + +;;; prelude-global-keybindings.el ends here diff --git a/prelude-haskell.el b/prelude-haskell.el new file mode 100644 index 0000000..7347168 --- /dev/null +++ b/prelude-haskell.el @@ -0,0 +1,40 @@ +;;; prelude-haskell.el --- Emacs Prelude: Nice config for Haskell programming. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Nice config for Haskell programming. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) +(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) + +(provide 'prelude-haskell) + +;;; prelude-haskell.el ends here diff --git a/prelude-lisp.el b/prelude-lisp.el new file mode 100644 index 0000000..6739b89 --- /dev/null +++ b/prelude-lisp.el @@ -0,0 +1,50 @@ +;;; prelude-lisp.el --- Emacs Prelude: Configuration common to all lisp modes. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Configuration shared between all modes related to lisp-like languages. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +;; Lisp configuration +(define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol) + +;; a great lisp coding hook +(defun prelude-lisp-coding-hook () + (prelude-coding-hook) + (paredit-mode +1)) + +;; interactive modes don't need whitespace checks +(defun prelude-interactive-lisp-coding-hook () + (paredit-mode +1) + (prelude-turn-off-whitespace)) + +(provide 'prelude-lisp) + +;;; prelude-lisp.el ends here diff --git a/prelude-packages.el b/prelude-packages.el new file mode 100644 index 0000000..65ea8eb --- /dev/null +++ b/prelude-packages.el @@ -0,0 +1,55 @@ +;;; prelude-packages.el --- Emacs Prelude: default package selection. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Takes care of the automatic installation of all the packages required by +;; Emacs Prelude. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'package) +(add-to-list 'package-archives + '("marmalade" . "http://marmalade-repo.org/packages/") t) +(package-initialize) + +(when (not package-archive-contents) + (package-refresh-contents)) + +(defvar prelude-packages '(auctex clojure-mode coffee-mode gist haml-mode + haskell-mode magit markdown-mode paredit + sass-mode yaml yari yasnippet) + "A list of packages to ensure are installed at launch.") + +(dolist (p prelude-packages) + (when (not (package-installed-p p)) + (package-install p))) + +(provide 'packages-prelude) + +;;; prelude-packages.el ends here diff --git a/prelude-ruby.el b/prelude-ruby.el new file mode 100644 index 0000000..0925698 --- /dev/null +++ b/prelude-ruby.el @@ -0,0 +1,80 @@ +;;; prelude-ruby.el --- Emacs Prelude: A nice setup for Ruby (and Rails) devs. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some basic configuration for Ruby and Rails development. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles. +(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode)) +(add-to-list 'auto-mode-alist '("Guardfile$" . ruby-mode)) + +;; We never want to edit Rubinius bytecode +(add-to-list 'completion-ignored-extensions ".rbc") + +(autoload 'run-ruby "inf-ruby" + "Run an inferior Ruby process") +(autoload 'inf-ruby-keys "inf-ruby" + "Set local key defs for inf-ruby in ruby-mode") + +;; yari provides a nice Emacs interface to ri +(require 'yari) + +; TODO fix ruby-end and package ruby-block for marmalade +;(require 'ruby-block) +;(require 'ruby-end) + +(defun prelude-ruby-mode-hook () + (prelude-coding-hook) + (inf-ruby-keys) + ;; turn off the annoying input echo in irb + (setq comint-process-echoes t) + ;(ruby-block-mode t) + (local-set-key (kbd "C-h r") 'yari)) + +(add-hook 'ruby-mode-hook 'prelude-ruby-mode-hook) + +(require 'haml-mode) +(require 'scss-mode) + +;; cucumber support +;(require 'feature-mode) +;(add-to-list 'auto-mode-alist '("\.feature$" . feature-mode)) + +;; load bundle snippets +;(yas/load-directory (concat ext-dir "feature-mode/snippets")) + +(provide 'prelude-ruby) + +;;; prelude-ruby.el ends here diff --git a/prelude-ui.el b/prelude-ui.el new file mode 100644 index 0000000..c59438a --- /dev/null +++ b/prelude-ui.el @@ -0,0 +1,66 @@ +;;; prelude-ui.el --- Emacs Prelude: UI optimizations and tweaks. +;; +;; Copyright (c) 2011 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov +;; URL: http://www.emacswiki.org/cgi-bin/wiki/Prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; We dispense with most of the point and click UI, reduce the startup noise, +;; configure smooth scolling and a nice theme that's easy on the eyes (zenburn). + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +;; the toolbar is just a waste of valuable screen estate +(tool-bar-mode -1) +;; the menu bar is mostly useless as well +;; but removing it under OS X doesn't make much sense +(unless (string= system-type "darwin") + (menu-bar-mode -1)) +;; the blinking cursor is nothing, but an annoyance +(blink-cursor-mode -1) + +;; disable startup screen +(setq inhibit-startup-screen t) + +;; nice scrolling +(setq scroll-margin 0 + scroll-conservatively 100000 + scroll-preserve-screen-position 1) + +;; mode line settings +(line-number-mode t) +(column-number-mode t) +(size-indication-mode t) + +;; enable y/n answers +(fset 'yes-or-no-p 'y-or-n-p) + +;; custom Emacs 24 color themes support +(add-to-list 'custom-theme-load-path (concat prelude-dir "themes/")) +(load-theme 'zenburn t) + +(provide 'prelude-ui) +;;; prelude-ui.el ends here diff --git a/ui-prelude.el b/ui-prelude.el deleted file mode 100644 index d92c553..0000000 --- a/ui-prelude.el +++ /dev/null @@ -1,30 +0,0 @@ -;; the toolbar is just a waste of valuable screen estate -(tool-bar-mode -1) -;; the menu bar is mostly useless as well -;; but removing it under OS X doesn't make much sense -(unless (string= system-type "darwin") - (menu-bar-mode -1)) -;; the blinking cursor is nothing, but an annoyance -(blink-cursor-mode -1) - -;; disable startup screen -(setq inhibit-startup-screen t) - -;; nice scrolling -(setq scroll-margin 0 - scroll-conservatively 100000 - scroll-preserve-screen-position 1) - -;; mode line settings -(line-number-mode t) -(column-number-mode t) -(size-indication-mode t) - -;; enable y/n answers -(fset 'yes-or-no-p 'y-or-n-p) - -;; custom Emacs 24 color themes support -(add-to-list 'custom-theme-load-path (concat prelude-dir "themes/")) -(load-theme 'zenburn t) - -(provide 'ui-prelude) diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 0000000..e69de29