added basic customization support

This commit is contained in:
Bozhidar Batsov 2011-10-15 13:04:02 +03:00
parent 051275833b
commit b4dd55883f
12 changed files with 297 additions and 146 deletions

View file

@ -33,6 +33,10 @@
;;; Code: ;;; Code:
(defgroup prelude nil
"Emacs Prelude"
:group 'convenience)
;; On OS X Emacs doesn't use the shell PATH if it's not started from ;; On OS X Emacs doesn't use the shell PATH if it's not started from
;; the shell. If you're using homebrew modifying the PATH is essential. ;; the shell. If you're using homebrew modifying the PATH is essential.
(if (string= system-type "darwin") (if (string= system-type "darwin")

View file

@ -32,13 +32,24 @@
;;; Code: ;;; Code:
;; customize
(defgroup c nil
"Emacs Prelude C programming support"
:group 'prelude)
(defcustom prelude-enable-c-hook t
"Enable Prelude's default C hook."
:type 'boolean
:group 'c)
(defun prelude-c-coding-hook () (defun prelude-c-coding-hook ()
(setq c-basic-offset 4) (setq c-basic-offset 4)
(prelude-coding-hook)) (prelude-coding-hook))
(when prelude-enable-c-hook
;; this will affect all modes derived from cc-mode, like ;; this will affect all modes derived from cc-mode, like
;; java-mode, php-mode, etc ;; java-mode, php-mode, etc
(add-hook 'c-mode-common-hook 'prelude-c-coding-hook) (add-hook 'c-mode-common-hook 'prelude-c-coding-hook))
(provide 'prelude-c) (provide 'prelude-c)

View file

@ -32,6 +32,16 @@
;;; Code: ;;; Code:
;; customize
(defgroup clojure nil
"Emacs Prelude Clojure programming support"
:group 'prelude)
(defcustom prelude-enable-clojure-hook t
"Enable Prelude's Clojure hook."
:type 'boolean
:group 'clojure)
(require 'prelude-lisp) (require 'prelude-lisp)
;; To start SLIME in your Clojure project: ;; To start SLIME in your Clojure project:
@ -39,7 +49,8 @@
;; 2. Invoke M-x clojure-jack-in from a project ;; 2. Invoke M-x clojure-jack-in from a project
(require 'clojure-mode) (require 'clojure-mode)
(add-hook 'clojure-mode-hook 'prelude-lisp-coding-hook) (when prelude-enable-clojure-hook
(add-hook 'clojure-mode-hook 'prelude-lisp-coding-hook))
(provide 'prelude-clojure) (provide 'prelude-clojure)

View file

@ -32,6 +32,15 @@
;;; Code: ;;; Code:
(defgroup coffee nil
"Emacs Prelude CoffeeScript support"
:group 'prelude)
(defcustom prelude-enable-coffee-hook t
"Enable Prelude's CoffeeScript's hook"
:type 'boolean
:group 'coffee)
(require 'coffee-mode) (require 'coffee-mode)
(defun prelude-coffee-mode-hook () (defun prelude-coffee-mode-hook ()
@ -64,7 +73,8 @@
(file-exists-p (coffee-compiled-file-name)) (file-exists-p (coffee-compiled-file-name))
(coffee-cos-mode t))) (coffee-cos-mode t)))
(add-hook 'coffee-mode-hook 'prelude-coffee-mode-hook) (when prelude-enable-coffee-hook
(add-hook 'coffee-mode-hook 'prelude-coffee-mode-hook))
(provide 'prelude-coffee) (provide 'prelude-coffee)

View file

@ -32,6 +32,27 @@
;;; Code: ;;; Code:
(defgroup common-lisp nil
"Prelude's Common Lisp support"
:group 'prelude)
(defcustom prelude-start-slime-automatically t
"Start SLIME automatically the first time a .list file is opened."
:type 'boolean
:group 'common-lisp)
(defcustom prelude-enable-common-lisp-hook t
"Enable Prelude's Common Lisp hook"
:type 'boolean
:group 'common-lisp)
(defcustom prelude-load-common-lisp-slime-automatically nil
"Load Common Lisp's SLIME by default. Setting this to `t' is not a
very good idea if you're programming on occasion in both Clojure and
Common Lisp."
:type 'boolean
:group 'common-lisp)
(require 'prelude-lisp) (require 'prelude-lisp)
;; the SBCL configuration file is in Common Lisp ;; the SBCL configuration file is in Common Lisp
@ -43,8 +64,7 @@
;; Common Lisp support depends on SLIME being installed with Quicklisp ;; Common Lisp support depends on SLIME being installed with Quicklisp
(if (file-exists-p (expand-file-name "~/quicklisp/slime-helper.el")) (if (file-exists-p (expand-file-name "~/quicklisp/slime-helper.el"))
(load (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.")) (message "%s" "SLIME is not installed. Use Quicklisp to install it.")))
)
;; a list of alternative Common Lisp implementations that can be ;; a list of alternative Common Lisp implementations that can be
;; used with SLIME. Note that their presence render ;; used with SLIME. Note that their presence render
@ -58,17 +78,23 @@
(sbcl ("sbcl" "--noinform") :coding-system utf-8-unix))) (sbcl ("sbcl" "--noinform") :coding-system utf-8-unix)))
;; select the default value from slime-lisp-implementations ;; select the default value from slime-lisp-implementations
(setq slime-default-lisp 'sbcl) (if (string= system-type "darwin")
;; default to Clozure CL on OS X
(setq slime-default-lisp 'ccl)
;; default to SBCL on Linux and Windows
(setq slime-default-lisp 'sbcl))
(when prelude-enable-common-lisp-hook
(add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook) (add-hook 'lisp-mode-hook 'prelude-lisp-coding-hook)
(add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook) (add-hook 'slime-repl-mode-hook 'prelude-interactive-lisp-coding-hook))
;; start slime automatically when we open a lisp file ;; start slime automatically when we open a lisp file
(defun prelude-start-slime () (defun prelude-start-slime ()
(unless (slime-connected-p) (unless (slime-connected-p)
(save-excursion (slime)))) (save-excursion (slime))))
(add-hook 'slime-mode-hook 'prelude-start-slime) (when prelude-start-slime-automatically
(add-hook 'slime-mode-hook 'prelude-start-slime))
;; Stop SLIME's REPL from grabbing DEL, ;; Stop SLIME's REPL from grabbing DEL,
;; which is annoying when backspacing over a '(' ;; which is annoying when backspacing over a '('

View file

@ -36,6 +36,11 @@
(require 'thingatpt) (require 'thingatpt)
(require 'imenu) (require 'imenu)
;; customization
(defgroup core nil
"Emacs Prelude core"
:group 'prelude)
(defun prelude-add-subfolders-to-load-path (parent-dir) (defun prelude-add-subfolders-to-load-path (parent-dir)
"Adds all first level `parent-dir' subdirs to the "Adds all first level `parent-dir' subdirs to the
Emacs load path." Emacs load path."

View file

@ -32,6 +32,11 @@
;;; Code: ;;; Code:
;; customize
(defgroup editor nil
"Emacs Prelude Editor enhancements"
:group 'prelude)
;; Emacs users obviously have little need for Command and Option keys, ;; Emacs users obviously have little need for Command and Option keys,
;; but they do need Meta and Super ;; but they do need Meta and Super
(when (string= system-type "darwin") (when (string= system-type "darwin")
@ -160,6 +165,10 @@
(require 'yasnippet) ;; not yasnippet-bundle (require 'yasnippet) ;; not yasnippet-bundle
(yas/initialize) (yas/initialize)
;; dispense of trailing whitespace once and for all
(add-hook 'before-save-hook
'delete-trailing-whitespace)
;; projectile is a project management mode ;; projectile is a project management mode
(require 'projectile) (require 'projectile)
(projectile-global-mode t) (projectile-global-mode t)

View file

@ -32,17 +32,17 @@
;;; Code: ;;; Code:
(defgroup emacs-lisp nil
"Prelude support for Emacs Lisp"
:group 'prelude)
(defcustom prelude-enable-emacs-lisp-hook t
"Enable Prelude's Emacs Lisp hook"
:type 'boolean
:group 'emacs-lisp)
(require 'prelude-lisp) (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 () (defun prelude-remove-elc-on-save ()
"If you're saving an elisp file, likely the .elc is no longer valid." "If you're saving an elisp file, likely the .elc is no longer valid."
(make-local-variable 'after-save-hook) (make-local-variable 'after-save-hook)
@ -51,6 +51,15 @@
(if (file-exists-p (concat buffer-file-name "c")) (if (file-exists-p (concat buffer-file-name "c"))
(delete-file (concat buffer-file-name "c")))))) (delete-file (concat buffer-file-name "c"))))))
(when prelude-enable-emacs-lisp-hook
(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))
(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point) (define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)
(provide 'prelude-emacs-lisp) (provide 'prelude-emacs-lisp)

View file

@ -32,6 +32,17 @@
;;; Code: ;;; Code:
(defcustom prelude-enable-additional-keybindings t
"Enable Prelude additional global keybindings"
:type 'boolean
:group 'prelude)
(defcustom prelude-disable-arrow-navigation t
"Disable arrow navigation"
:type 'boolean
:group 'prelude)
(when prelude-enable-additional-keybindings
;; You know, like Readline. ;; You know, like Readline.
(global-set-key (kbd "C-M-h") 'backward-kill-word) (global-set-key (kbd "C-M-h") 'backward-kill-word)
@ -131,8 +142,9 @@
(global-set-key (kbd "C-c g") 'prelude-google) (global-set-key (kbd "C-c g") 'prelude-google)
;; toggle menu-bar visibility ;; toggle menu-bar visibility
(global-set-key (kbd "<f12>") 'menu-bar-mode) (global-set-key (kbd "<f12>") 'menu-bar-mode))
(when prelude-disable-arrow-navigation
;; real Emacs hackers don't use the arrow keys ;; real Emacs hackers don't use the arrow keys
(global-set-key (kbd "<up>") (lambda () (global-set-key (kbd "<up>") (lambda ()
(interactive) (interactive)
@ -145,7 +157,7 @@
(message "Arrow key navigation is disabled. Use C-b instead."))) (message "Arrow key navigation is disabled. Use C-b instead.")))
(global-set-key (kbd "<right>") (lambda () (global-set-key (kbd "<right>") (lambda ()
(interactive) (interactive)
(message "Arrow key navigation is disabled. Use C-f instead."))) (message "Arrow key navigation is disabled. Use C-f instead."))))
(provide 'prelude-global-keybindings) (provide 'prelude-global-keybindings)

View file

@ -32,6 +32,15 @@
;;; Code: ;;; Code:
(defgroup perl nil
"Emacs Prelude Perl support."
:group 'prelude)
(defcustom prelude-enable-perl-hook t
"Enable Prelude's Perl hook"
:type 'boolean
:group 'perl)
;; use cperl-mode instead of perl-mode ;; use cperl-mode instead of perl-mode
(defalias 'perl-mode 'cperl-mode) (defalias 'perl-mode 'cperl-mode)
@ -56,7 +65,8 @@
(set-face-background 'cperl-hash-face nil) (set-face-background 'cperl-hash-face nil)
(setq cperl-invalid-face nil)) (setq cperl-invalid-face nil))
(add-hook 'cperl-mode-hook 'prelude-cperl-mode-hook t) (when prelude-enable-perl-hook
(add-hook 'cperl-mode-hook 'prelude-cperl-mode-hook t))
(provide 'prelude-perl) (provide 'prelude-perl)

View file

@ -32,6 +32,15 @@
;;; Code: ;;; Code:
(defgroup ruby nil
"Emacs Prelude Ruby support"
:group 'prelude)
(defcustom prelude-enable-ruby-hook t
"Enable Prelude's Ruby hook"
:type 'boolean
:group 'ruby)
;; Rake files are ruby, too, as are gemspecs, rackup files, and gemfiles. ;; 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 '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode)) (add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
@ -63,7 +72,8 @@
(ruby-block-mode t) (ruby-block-mode t)
(local-set-key (kbd "C-h r") 'yari)) (local-set-key (kbd "C-h r") 'yari))
(add-hook 'ruby-mode-hook 'prelude-ruby-mode-hook) (when prelude-enable-ruby-hook
(add-hook 'ruby-mode-hook 'prelude-ruby-mode-hook))
(require 'haml-mode) (require 'haml-mode)
(require 'scss-mode) (require 'scss-mode)

View file

@ -33,6 +33,35 @@
;;; Code: ;;; Code:
;; customization
(defgroup ui nil
"Emacs Prelude UI"
:group 'prelude)
(defcustom prelude-use-minimalistic-ui t
"If set to true Prelude will dispense of most the UI that's mouse related -
menu bar, tool bar, etc"
:type 'boolean
:group 'ui)
(defcustom prelude-use-smooth-scrolling t
"Overrides the default scrolling behavior with a much more common one."
:type 'boolean
:group 'ui)
(defcustom prelude-use-default-prelude-theme t
"If set to true Prelude will load up its default theme (Zenburn),
instead of Emacs's default theme."
:type 'boolean
:group 'ui)
(defcustom prelude-enhance-modeline t
"If set to true Prelude will augment the default modeline settings."
:type 'boolean
:group 'ui)
(when prelude-use-minimalistic-ui
;; the toolbar is just a waste of valuable screen estate ;; the toolbar is just a waste of valuable screen estate
(tool-bar-mode -1) (tool-bar-mode -1)
;; the menu bar is mostly useless as well ;; the menu bar is mostly useless as well
@ -43,24 +72,29 @@
(blink-cursor-mode -1) (blink-cursor-mode -1)
;; disable startup screen ;; disable startup screen
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t))
(when prelude-use-smooth-scrolling
;; nice scrolling ;; nice scrolling
(setq scroll-margin 0 (setq scroll-margin 0
scroll-conservatively 100000 scroll-conservatively 100000
scroll-preserve-screen-position 1) scroll-preserve-screen-position 1))
(when prelude-enhance-modeline
;; mode line settings ;; mode line settings
(line-number-mode t) (line-number-mode t)
(column-number-mode t) (column-number-mode t)
(size-indication-mode t) (size-indication-mode t))
;; enable y/n answers ;; enable y/n answers
(fset 'yes-or-no-p 'y-or-n-p) (fset 'yes-or-no-p 'y-or-n-p)
;; custom Emacs 24 color themes support ;; custom Emacs 24 color themes support
(add-to-list 'custom-theme-load-path (concat prelude-dir "themes/")) (add-to-list 'custom-theme-load-path (concat prelude-dir "themes/"))
(load-theme 'zenburn t)
(when prelude-use-default-prelude-theme
(load-theme 'zenburn t))
(provide 'prelude-ui) (provide 'prelude-ui)
;;; prelude-ui.el ends here ;;; prelude-ui.el ends here