Skip to content

Commit

Permalink
Extract remaining config blocks in init.el into separate init files b…
Browse files Browse the repository at this point in the history
…y topic
  • Loading branch information
purcell committed Feb 20, 2010
1 parent 9c48287 commit 2a0413c
Show file tree
Hide file tree
Showing 42 changed files with 807 additions and 917 deletions.
47 changes: 47 additions & 0 deletions init-auto-complete.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(setq ac-auto-start nil)
(setq ac-dwim t)
(define-key ac-complete-mode-map (kbd "C-n") 'ac-next)
(define-key ac-complete-mode-map (kbd "C-p") 'ac-previous)

(defun indent-or-expand-with-ac (&optional arg)
"Either indent according to mode, or expand the word preceding point."
(interactive "*P")
(if (and
(not mark-active)
(not (minibufferp))
(memq 'auto-complete-mode minor-mode-list)
(looking-at "\\_>"))
(ac-start)
(indent-for-tab-command arg)))

(global-set-key (kbd "TAB") 'indent-or-expand-with-ac)

(set-default 'ac-sources
'(ac-source-words-in-buffer
ac-source-words-in-same-mode-buffers
ac-source-words-in-all-buffer))

(dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
sass-mode yaml-mode csv-mode espresso-mode haskell-mode
html-mode nxml-mode sh-mode smarty-mode clojure-mode
lisp-mode textile-mode markdown-mode tuareg-mode))
(add-to-list 'ac-modes mode))


(eval-after-load "viper"
'(progn
(define-key ac-complete-mode-map (kbd "C-n") 'dabbrev-expand)
(define-key ac-complete-mode-map (kbd "C-p") 'dabbrev-expand)
(define-key ac-complete-mode-map viper-ESC-key 'viper-intercept-ESC-key)))

;; Exclude very large buffers from dabbrev
(defun smp-dabbrev-friend-buffer (other-buffer)
(< (buffer-size other-buffer) (* 1 1024 1024)))

(setq dabbrev-friend-buffer-function 'smp-dabbrev-friend-buffer)


(provide 'init-auto-complete)
4 changes: 4 additions & 0 deletions init-crontab.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(autoload 'crontab-mode "crontab-mode" "Mode for editing crontab files" t)
(add-auto-mode 'crontab-mode "\\.?cron\\(tab\\)?\\'")

(provide 'init-crontab)
6 changes: 6 additions & 0 deletions init-csv.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(autoload 'csv-mode "csv-mode" "Major mode for editing comma-separated value files." t)
(add-auto-mode 'csv-mode "\\.[Cc][Ss][Vv]\\'")
(autoload 'csv-nav-mode "csv-nav-mode" "Major mode for navigating comma-separated value files." t)


(provide 'init-csv)
6 changes: 6 additions & 0 deletions init-dired.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(require 'dired+)
(setq dired-recursive-deletes 'top)
(define-key dired-mode-map [mouse-2] 'dired-find-file)


(provide 'init-dired)
6 changes: 6 additions & 0 deletions init-edit-server.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(require 'edit-server)
(setq edit-server-new-frame nil)
(edit-server-start t)


(provide 'init-edit-server)
137 changes: 137 additions & 0 deletions init-editing-utils.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
;;----------------------------------------------------------------------------
;; Overwrite text when the selection is active
;;----------------------------------------------------------------------------
(delete-selection-mode 1)


;;----------------------------------------------------------------------------
;; Show and edit all lines matching a regex
;;----------------------------------------------------------------------------
(require 'all)


;;----------------------------------------------------------------------------
;; Don't disable case-change functions
;;----------------------------------------------------------------------------
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)


;;----------------------------------------------------------------------------
;; Rectangle selections
;;----------------------------------------------------------------------------
(setq cua-enable-cua-keys nil) ;; only for rectangles, with C-RET
(cua-mode t)


;;----------------------------------------------------------------------------
;; Conversion of line endings
;;----------------------------------------------------------------------------
;; Can also use "C-x ENTER f dos" / "C-x ENTER f unix" (set-buffer-file-coding-system)
(require 'eol-conversion)


;;----------------------------------------------------------------------------
;; Handy key bindings
;;----------------------------------------------------------------------------
;; To be able to M-x without meta
(global-set-key (kbd "C-x C-m") 'execute-extended-command)

(global-set-key (kbd "C-c j") 'join-line)
(global-set-key (kbd "C-c J") (lambda () (interactive) (join-line 1)))
(global-set-key (kbd "M-T") 'transpose-lines)

(defun duplicate-line ()
(interactive)
(save-excursion
(let ((line-text (buffer-substring-no-properties
(line-beginning-position)
(line-end-position))))
(move-end-of-line 1)
(newline)
(insert line-text))))

(global-set-key (kbd "C-c p") 'duplicate-line)

;; Train myself to use M-f and M-b instead
(global-unset-key [M-left])
(global-unset-key [M-right])


;;----------------------------------------------------------------------------
;; Shift lines up and down
;;----------------------------------------------------------------------------
(defun move-text-internal (arg)
(cond
((and mark-active transient-mark-mode)
(if (> (point) (mark))
(exchange-point-and-mark))
(let ((column (current-column))
(text (delete-and-extract-region (point) (mark))))
(forward-line arg)
(move-to-column column t)
(set-mark (point))
(insert text)
(exchange-point-and-mark)
(setq deactivate-mark nil)))
(t
(let ((column (current-column)))
(beginning-of-line)
(when (or (> arg 0) (not (bobp)))
(forward-line)
(when (or (< arg 0) (not (eobp)))
(transpose-lines arg))
(forward-line -1))
(move-to-column column t)))))

(defun move-text-down (arg)
"Move region (transient-mark-mode active) or current line
arg lines down."
(interactive "*p")
(move-text-internal arg))

(defun move-text-up (arg)
"Move region (transient-mark-mode active) or current line
arg lines up."
(interactive "*p")
(move-text-internal (- arg)))


(global-set-key [M-S-up] 'move-text-up)
(global-set-key [M-S-down] 'move-text-down)



;;----------------------------------------------------------------------------
;; Cut/copy the current line if no region is active
;;----------------------------------------------------------------------------
(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))
(message "Killed line")
(list (line-beginning-position)
(line-beginning-position 2)))))


;;----------------------------------------------------------------------------
;; Easily count words (http://emacs-fu.blogspot.com/2009/01/counting-words.html)
;;----------------------------------------------------------------------------
(defun count-words (&optional begin end)
"count words between BEGIN and END (region); if no region defined, count words in buffer"
(interactive "r")
(let ((b (if mark-active begin (point-min)))
(e (if mark-active end (point-max))))
(message "Word count: %s" (how-many "\\w+" b e))))




(provide 'init-editing-utils)
6 changes: 6 additions & 0 deletions init-elpa.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(require 'package)
(add-to-list 'package-archives
'("technomancy" . "http://repo.technomancy.us/emacs/") t)
(package-initialize)

(provide 'init-elpa)
15 changes: 15 additions & 0 deletions init-exec-path.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell (shell-command-to-string "$SHELL -i -c 'echo $PATH'")))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))

(when *is-a-mac*
(eval-after-load "woman"
'(setq woman-manpath (append (list "/opt/local/man") woman-manpath)))

;; When started from Emacs.app or similar, ensure $PATH
;; is the same the user would see in Terminal.app
(if window-system (set-exec-path-from-shell-PATH)))


(provide 'init-exec-path)
3 changes: 3 additions & 0 deletions init-flyspell.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
;;----------------------------------------------------------------------------
;; Add spell-checking in comments for all programming language modes
;;----------------------------------------------------------------------------
(dolist (hook '(lisp-mode-hook
emacs-lisp-mode-hook
scheme-mode-hook
Expand Down
17 changes: 17 additions & 0 deletions init-frame-hooks.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(defvar after-make-console-frame-hooks '()
"Hooks to run after creating a new TTY frame")
(defvar after-make-window-system-frame-hooks '()
"Hooks to run after creating a new window-system frame")

(defun run-after-make-frame-hooks (frame)
"Selectively run either `after-make-console-frame-hooks' or
`after-make-window-system-frame-hooks'"
(select-frame frame)
(run-hooks (if window-system
'after-make-window-system-frame-hooks
'after-make-console-frame-hooks)))

(add-hook 'after-make-frame-functions 'run-after-make-frame-hooks)


(provide 'init-frame-hooks)
5 changes: 5 additions & 0 deletions init-gnuplot.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
(autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)


(provide 'init-gnuplot)
5 changes: 5 additions & 0 deletions init-growl.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(require 'todochiku) ;; growl notifications when compilation finishes
(add-hook 'compilation-mode-hook (lambda () (local-set-key [f6] 'recompile)))


(provide 'init-growl)
60 changes: 60 additions & 0 deletions init-gui-frames.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;;----------------------------------------------------------------------------
;; Stop C-z from minimizing windows under OS X
;;----------------------------------------------------------------------------
(global-set-key (kbd "C-z")
(lambda ()
(interactive)
(unless (and *is-a-mac* window-system)
(suspend-frame))))


;;----------------------------------------------------------------------------
;; Suppress GUI features
;;----------------------------------------------------------------------------
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(setq inhibit-startup-screen t)


;;----------------------------------------------------------------------------
;; Show a marker in the left fringe for lines not in the buffer
;;----------------------------------------------------------------------------
(setq default-indicate-empty-lines t)


;;----------------------------------------------------------------------------
;; Window size and features
;;----------------------------------------------------------------------------
(tool-bar-mode -1)
(scroll-bar-mode -1)
(set-fringe-mode 1)

(require 'init-maxframe)

(defun adjust-opacity (frame incr)
(let* ((oldalpha (or (frame-parameter frame 'alpha) 100))
(newalpha (+ incr oldalpha)))
(when (and (<= frame-alpha-lower-limit newalpha) (>= 100 newalpha))
(modify-frame-parameters frame (list (cons 'alpha newalpha))))))

(when (fboundp 'ns-toggle-fullscreen)
;; Command-Option-f to toggle fullscreen mode
(global-set-key (kbd "M-ƒ") 'ns-toggle-fullscreen))

(global-set-key (kbd "C-8") '(lambda () (interactive) (adjust-opacity nil -5)))
(global-set-key (kbd "C-9") '(lambda () (interactive) (adjust-opacity nil 5)))
(global-set-key (kbd "C-0") '(lambda () (interactive) (modify-frame-parameters nil `((alpha . 100)))))

(add-hook 'after-make-frame-functions
(lambda (frame)
(let ((prev-frame (selected-frame)))
(select-frame frame)
(prog1
(unless window-system
(set-frame-parameter frame 'menu-bar-lines 0))
(select-frame prev-frame)))))




(provide 'init-gui-frames)
10 changes: 10 additions & 0 deletions init-hippie-expand.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(global-set-key (kbd "M-/") 'hippie-expand)

(setq hippie-expand-try-functions-list
'(try-complete-file-name-partially
try-complete-file-name
try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill))

(provide 'init-hippie-expand)
7 changes: 7 additions & 0 deletions init-htmlize.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(dolist (sym
(list 'htmlize-file 'htmlize-region 'htmlize-buffer
'htmlize-many-files 'htmlize-many-files-dired))
(autoload sym "htmlize"))


(provide 'init-htmlize)
Loading

0 comments on commit 2a0413c

Please sign in to comment.