some more groundwork

This commit is contained in:
Bozhidar Batsov 2011-10-08 23:05:06 +03:00
parent a2380fa7d6
commit 301d057078
17 changed files with 1095 additions and 95 deletions

View file

@ -1 +0,0 @@
(provide 'core-prelude)

56
init.el
View file

@ -1,9 +1,55 @@
;;; init.el --- Emacs Prelude: configuration entry point.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

View file

@ -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)

45
prelude-c.el Normal file
View file

@ -0,0 +1,45 @@
;;; prelude-c.el --- Emacs Prelude: cc-mode configuration.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

46
prelude-clojure.el Normal file
View file

@ -0,0 +1,46 @@
;;; prelude-clojure.el --- Emacs Prelude: Clojure programming configuration.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

94
prelude-common-lisp.el Normal file
View file

@ -0,0 +1,94 @@
;;; prelude-common-lisp.el --- Emacs Prelude: lisp-mode and SLIME config.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

411
prelude-core.el Normal file
View file

@ -0,0 +1,411 @@
;;; prelude-core.el --- Emacs Prelude: core Prelude defuns.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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 "<?xml" nil t) (xml-mode))
((search-forward "<html" nil t) (html-mode)))))
(defun prelude-ido-goto-symbol (&optional symbol-list)
"Refresh imenu and jump to a place in the buffer using Ido."
(interactive)
(unless (featurep 'imenu)
(require 'imenu nil t))
(cond
((not symbol-list)
(let ((ido-mode ido-mode)
(ido-enable-flex-matching
(if (boundp 'ido-enable-flex-matching)
ido-enable-flex-matching t))
name-and-pos symbol-names position)
(unless ido-mode
(ido-mode 1)
(setq ido-enable-flex-matching t))
(while (progn
(imenu--cleanup)
(setq imenu--index-alist nil)
(ido-goto-symbol (imenu--make-index-alist))
(setq selected-symbol
(ido-completing-read "Symbol? " symbol-names))
(string= (car imenu--rescan-item) selected-symbol)))
(unless (and (boundp 'mark-active) mark-active)
(push-mark nil t nil))
(setq position (cdr (assoc selected-symbol name-and-pos)))
(cond
((overlayp position)
(goto-char (overlay-start position)))
(t
(goto-char position)))))
((listp symbol-list)
(dolist (symbol symbol-list)
(let (name position)
(cond
((and (listp symbol) (imenu--subalist-p symbol))
(ido-goto-symbol symbol))
((listp symbol)
(setq name (car symbol))
(setq position (cdr symbol)))
((stringp symbol)
(setq name symbol)
(setq position
(get-text-property 1 'org-imenu-marker symbol))))
(unless (or (null position) (null name)
(string= (car imenu--rescan-item) name))
(add-to-list 'symbol-names name)
(add-to-list 'name-and-pos (cons name position))))))))
;; We have a number of turn-on-* functions since it's advised that lambda
;; functions not go in hooks. Repeatedly evaluating an add-to-list with a
;; hook value will repeatedly add it since there's no way to ensure
;; that a lambda doesn't already exist in the list.
(defun prelude-local-comment-auto-fill ()
(set (make-local-variable 'comment-auto-fill-only-comments) t)
(auto-fill-mode t))
(defun prelude-turn-on-whitespace ()
(whitespace-mode +1))
(defun prelude-turn-off-whitespace ()
(whitespace-mode -1))
(defun prelude-turn-on-abbrev ()
(abbrev-mode +1))
(defun prelude-turn-off-abbrev ()
(abbrev-mode -1))
(defun prelude-add-watchwords ()
(font-lock-add-keywords
nil '(("\\<\\(FIX\\|TODO\\|FIXME\\|HACK\\|REFACTOR\\):"
1 font-lock-warning-face t))))
(defun prelude-coding-hook ()
"Default coding hook, useful with any programming language."
(flyspell-prog-mode)
(prelude-local-comment-auto-fill)
(prelude-turn-on-whitespace)
(prelude-turn-on-abbrev)
(prelude-add-watchwords))
(defun prelude-untabify-buffer ()
(interactive)
(untabify (point-min) (point-max)))
(defun prelude-cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer."
(interactive)
(prelude-indent-buffer)
(prelude-untabify-buffer)
(prelude-delete-trailing-whitespace))
(defun prelude-eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
(backward-kill-sexp)
(condition-case nil
(prin1 (eval (read (current-kill 0)))
(current-buffer))
(error (message "Invalid expression")
(insert (current-kill 0)))))
(defun prelude-recompile-init ()
"Byte-compile all your dotfiles again."
(interactive)
(byte-recompile-directory prelude-dir 0)
(byte-recompile-directory vendor-dir 0))
(defun prelude-regen-autoloads (&optional force-regen)
"Regenerate the autoload definitions file if necessary and load it."
(interactive "P")
(let ((autoload-dir vendor-dir)
(generated-autoload-file autoload-file))
(when (or force-regen
(not (file-exists-p autoload-file))
(some (lambda (f) (file-newer-than-file-p f autoload-file))
(directory-files autoload-dir t "\\.el$")))
(message "Updating autoloads...")
(let (emacs-lisp-mode-hook)
(update-directory-autoloads autoload-dir))))
(load autoload-file))
(defun prelude-sudo-edit (&optional arg)
(interactive "p")
(if (or arg (not buffer-file-name))
(find-file (concat "/sudo:root@localhost:" (ido-read-file-name "File: ")))
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name))))
(defun prelude-switch-or-start (function buffer)
"If the buffer is current, bury it, otherwise invoke the function."
(if (equal (buffer-name (current-buffer)) buffer)
(bury-buffer)
(if (get-buffer buffer)
(switch-to-buffer buffer)
(funcall function))))
(defun prelude-insert-date ()
"Insert a time-stamp according to locale's date and time format."
(interactive)
(insert (format-time-string "%c" (current-time))))
(defun prelude-conditionally-enable-paredit-mode ()
"Enable paredit-mode in the minibuffer, during eval-expression."
(if (eq this-command 'eval-expression)
(paredit-mode 1)))
(add-hook 'minibuffer-setup-hook 'prelude-conditionally-enable-paredit-mode)
(defun prelude-recentf-ido-find-file ()
"Find a recent file using ido."
(interactive)
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))
(defun prelude-swap-windows ()
"If you have 2 windows, it swaps them."
(interactive)
(cond ((/= (count-windows) 2)
(message "You need exactly 2 windows to do this."))
(t
(let* ((w1 (first (window-list)))
(w2 (second (window-list)))
(b1 (window-buffer w1))
(b2 (window-buffer w2))
(s1 (window-start w1))
(s2 (window-start w2)))
(set-window-buffer w1 b2)
(set-window-buffer w2 b1)
(set-window-start w1 s2)
(set-window-start w2 s1))))
(other-window 1))
(provide 'prelude-core)
;;; prelude-core.el ends here

View file

@ -1,3 +1,37 @@
;;; prelude-editor.el --- Emacs Prelude: enhanced core editing experience.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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")
@ -61,9 +95,9 @@
;; 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: <>
(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
@ -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,14 +132,15 @@
(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)
@ -125,4 +148,6 @@
(setq bookmark-default-file "~/.emacs.d/bookmarks"
bookmark-save-flag 1)
(provide 'editor-prelude)
(provide 'prelude-editor)
;;; prelude-editor.el ends here

58
prelude-emacs-lisp.el Normal file
View file

@ -0,0 +1,58 @@
;;; prelude-emacs-lisp.el --- Emacs Prelude: Nice config for Elisp programming.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

View file

@ -1,3 +1,37 @@
;;; prelude-global-keybindings.el --- Emacs Prelude: some useful keybindings.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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,26 +114,23 @@
;; 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 "<f12>") 'menu-bar-mode)
@ -118,4 +149,6 @@
(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

40
prelude-haskell.el Normal file
View file

@ -0,0 +1,40 @@
;;; prelude-haskell.el --- Emacs Prelude: Nice config for Haskell programming.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

50
prelude-lisp.el Normal file
View file

@ -0,0 +1,50 @@
;;; prelude-lisp.el --- Emacs Prelude: Configuration common to all lisp modes.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

55
prelude-packages.el Normal file
View file

@ -0,0 +1,55 @@
;;; prelude-packages.el --- Emacs Prelude: default package selection.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

80
prelude-ruby.el Normal file
View file

@ -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 <bozhidar.batsov@gmail.com>
;; 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

66
prelude-ui.el Normal file
View file

@ -0,0 +1,66 @@
;;; prelude-ui.el --- Emacs Prelude: UI optimizations and tweaks.
;;
;; Copyright (c) 2011 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
;; 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

View file

@ -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)

0
vendor/.gitkeep vendored Normal file
View file