Skip to content

Commit 2a0413c

Browse files
committed
Extract remaining config blocks in init.el into separate init files by topic
1 parent 9c48287 commit 2a0413c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+807
-917
lines changed

init-auto-complete.el

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(require 'auto-complete)
2+
(require 'auto-complete-config)
3+
(global-auto-complete-mode t)
4+
(setq ac-auto-start nil)
5+
(setq ac-dwim t)
6+
(define-key ac-complete-mode-map (kbd "C-n") 'ac-next)
7+
(define-key ac-complete-mode-map (kbd "C-p") 'ac-previous)
8+
9+
(defun indent-or-expand-with-ac (&optional arg)
10+
"Either indent according to mode, or expand the word preceding point."
11+
(interactive "*P")
12+
(if (and
13+
(not mark-active)
14+
(not (minibufferp))
15+
(memq 'auto-complete-mode minor-mode-list)
16+
(looking-at "\\_>"))
17+
(ac-start)
18+
(indent-for-tab-command arg)))
19+
20+
(global-set-key (kbd "TAB") 'indent-or-expand-with-ac)
21+
22+
(set-default 'ac-sources
23+
'(ac-source-words-in-buffer
24+
ac-source-words-in-same-mode-buffers
25+
ac-source-words-in-all-buffer))
26+
27+
(dolist (mode '(magit-log-edit-mode log-edit-mode org-mode text-mode haml-mode
28+
sass-mode yaml-mode csv-mode espresso-mode haskell-mode
29+
html-mode nxml-mode sh-mode smarty-mode clojure-mode
30+
lisp-mode textile-mode markdown-mode tuareg-mode))
31+
(add-to-list 'ac-modes mode))
32+
33+
34+
(eval-after-load "viper"
35+
'(progn
36+
(define-key ac-complete-mode-map (kbd "C-n") 'dabbrev-expand)
37+
(define-key ac-complete-mode-map (kbd "C-p") 'dabbrev-expand)
38+
(define-key ac-complete-mode-map viper-ESC-key 'viper-intercept-ESC-key)))
39+
40+
;; Exclude very large buffers from dabbrev
41+
(defun smp-dabbrev-friend-buffer (other-buffer)
42+
(< (buffer-size other-buffer) (* 1 1024 1024)))
43+
44+
(setq dabbrev-friend-buffer-function 'smp-dabbrev-friend-buffer)
45+
46+
47+
(provide 'init-auto-complete)

init-crontab.el

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(autoload 'crontab-mode "crontab-mode" "Mode for editing crontab files" t)
2+
(add-auto-mode 'crontab-mode "\\.?cron\\(tab\\)?\\'")
3+
4+
(provide 'init-crontab)

init-csv.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(autoload 'csv-mode "csv-mode" "Major mode for editing comma-separated value files." t)
2+
(add-auto-mode 'csv-mode "\\.[Cc][Ss][Vv]\\'")
3+
(autoload 'csv-nav-mode "csv-nav-mode" "Major mode for navigating comma-separated value files." t)
4+
5+
6+
(provide 'init-csv)

init-dired.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(require 'dired+)
2+
(setq dired-recursive-deletes 'top)
3+
(define-key dired-mode-map [mouse-2] 'dired-find-file)
4+
5+
6+
(provide 'init-dired)

init-edit-server.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(require 'edit-server)
2+
(setq edit-server-new-frame nil)
3+
(edit-server-start t)
4+
5+
6+
(provide 'init-edit-server)

init-editing-utils.el

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
;;----------------------------------------------------------------------------
2+
;; Overwrite text when the selection is active
3+
;;----------------------------------------------------------------------------
4+
(delete-selection-mode 1)
5+
6+
7+
;;----------------------------------------------------------------------------
8+
;; Show and edit all lines matching a regex
9+
;;----------------------------------------------------------------------------
10+
(require 'all)
11+
12+
13+
;;----------------------------------------------------------------------------
14+
;; Don't disable case-change functions
15+
;;----------------------------------------------------------------------------
16+
(put 'upcase-region 'disabled nil)
17+
(put 'downcase-region 'disabled nil)
18+
19+
20+
;;----------------------------------------------------------------------------
21+
;; Rectangle selections
22+
;;----------------------------------------------------------------------------
23+
(setq cua-enable-cua-keys nil) ;; only for rectangles, with C-RET
24+
(cua-mode t)
25+
26+
27+
;;----------------------------------------------------------------------------
28+
;; Conversion of line endings
29+
;;----------------------------------------------------------------------------
30+
;; Can also use "C-x ENTER f dos" / "C-x ENTER f unix" (set-buffer-file-coding-system)
31+
(require 'eol-conversion)
32+
33+
34+
;;----------------------------------------------------------------------------
35+
;; Handy key bindings
36+
;;----------------------------------------------------------------------------
37+
;; To be able to M-x without meta
38+
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
39+
40+
(global-set-key (kbd "C-c j") 'join-line)
41+
(global-set-key (kbd "C-c J") (lambda () (interactive) (join-line 1)))
42+
(global-set-key (kbd "M-T") 'transpose-lines)
43+
44+
(defun duplicate-line ()
45+
(interactive)
46+
(save-excursion
47+
(let ((line-text (buffer-substring-no-properties
48+
(line-beginning-position)
49+
(line-end-position))))
50+
(move-end-of-line 1)
51+
(newline)
52+
(insert line-text))))
53+
54+
(global-set-key (kbd "C-c p") 'duplicate-line)
55+
56+
;; Train myself to use M-f and M-b instead
57+
(global-unset-key [M-left])
58+
(global-unset-key [M-right])
59+
60+
61+
;;----------------------------------------------------------------------------
62+
;; Shift lines up and down
63+
;;----------------------------------------------------------------------------
64+
(defun move-text-internal (arg)
65+
(cond
66+
((and mark-active transient-mark-mode)
67+
(if (> (point) (mark))
68+
(exchange-point-and-mark))
69+
(let ((column (current-column))
70+
(text (delete-and-extract-region (point) (mark))))
71+
(forward-line arg)
72+
(move-to-column column t)
73+
(set-mark (point))
74+
(insert text)
75+
(exchange-point-and-mark)
76+
(setq deactivate-mark nil)))
77+
(t
78+
(let ((column (current-column)))
79+
(beginning-of-line)
80+
(when (or (> arg 0) (not (bobp)))
81+
(forward-line)
82+
(when (or (< arg 0) (not (eobp)))
83+
(transpose-lines arg))
84+
(forward-line -1))
85+
(move-to-column column t)))))
86+
87+
(defun move-text-down (arg)
88+
"Move region (transient-mark-mode active) or current line
89+
arg lines down."
90+
(interactive "*p")
91+
(move-text-internal arg))
92+
93+
(defun move-text-up (arg)
94+
"Move region (transient-mark-mode active) or current line
95+
arg lines up."
96+
(interactive "*p")
97+
(move-text-internal (- arg)))
98+
99+
100+
(global-set-key [M-S-up] 'move-text-up)
101+
(global-set-key [M-S-down] 'move-text-down)
102+
103+
104+
105+
;;----------------------------------------------------------------------------
106+
;; Cut/copy the current line if no region is active
107+
;;----------------------------------------------------------------------------
108+
(defadvice kill-ring-save (before slick-copy activate compile) "When called
109+
interactively with no active region, copy a single line instead."
110+
(interactive (if mark-active (list (region-beginning) (region-end))
111+
(message "Copied line")
112+
(list (line-beginning-position)
113+
(line-beginning-position 2)))))
114+
115+
(defadvice kill-region (before slick-cut activate compile)
116+
"When called interactively with no active region, kill a single line instead."
117+
(interactive
118+
(if mark-active (list (region-beginning) (region-end))
119+
(message "Killed line")
120+
(list (line-beginning-position)
121+
(line-beginning-position 2)))))
122+
123+
124+
;;----------------------------------------------------------------------------
125+
;; Easily count words (http://emacs-fu.blogspot.com/2009/01/counting-words.html)
126+
;;----------------------------------------------------------------------------
127+
(defun count-words (&optional begin end)
128+
"count words between BEGIN and END (region); if no region defined, count words in buffer"
129+
(interactive "r")
130+
(let ((b (if mark-active begin (point-min)))
131+
(e (if mark-active end (point-max))))
132+
(message "Word count: %s" (how-many "\\w+" b e))))
133+
134+
135+
136+
137+
(provide 'init-editing-utils)

init-elpa.el

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(require 'package)
2+
(add-to-list 'package-archives
3+
'("technomancy" . "http://repo.technomancy.us/emacs/") t)
4+
(package-initialize)
5+
6+
(provide 'init-elpa)

init-exec-path.el

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(defun set-exec-path-from-shell-PATH ()
2+
(let ((path-from-shell (shell-command-to-string "$SHELL -i -c 'echo $PATH'")))
3+
(setenv "PATH" path-from-shell)
4+
(setq exec-path (split-string path-from-shell path-separator))))
5+
6+
(when *is-a-mac*
7+
(eval-after-load "woman"
8+
'(setq woman-manpath (append (list "/opt/local/man") woman-manpath)))
9+
10+
;; When started from Emacs.app or similar, ensure $PATH
11+
;; is the same the user would see in Terminal.app
12+
(if window-system (set-exec-path-from-shell-PATH)))
13+
14+
15+
(provide 'init-exec-path)

init-flyspell.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
;;----------------------------------------------------------------------------
2+
;; Add spell-checking in comments for all programming language modes
3+
;;----------------------------------------------------------------------------
14
(dolist (hook '(lisp-mode-hook
25
emacs-lisp-mode-hook
36
scheme-mode-hook

init-frame-hooks.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(defvar after-make-console-frame-hooks '()
2+
"Hooks to run after creating a new TTY frame")
3+
(defvar after-make-window-system-frame-hooks '()
4+
"Hooks to run after creating a new window-system frame")
5+
6+
(defun run-after-make-frame-hooks (frame)
7+
"Selectively run either `after-make-console-frame-hooks' or
8+
`after-make-window-system-frame-hooks'"
9+
(select-frame frame)
10+
(run-hooks (if window-system
11+
'after-make-window-system-frame-hooks
12+
'after-make-console-frame-hooks)))
13+
14+
(add-hook 'after-make-frame-functions 'run-after-make-frame-hooks)
15+
16+
17+
(provide 'init-frame-hooks)

init-gnuplot.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(autoload 'gnuplot-mode "gnuplot" "gnuplot major mode" t)
2+
(autoload 'gnuplot-make-buffer "gnuplot" "open a buffer in gnuplot-mode" t)
3+
4+
5+
(provide 'init-gnuplot)

init-growl.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(require 'todochiku) ;; growl notifications when compilation finishes
2+
(add-hook 'compilation-mode-hook (lambda () (local-set-key [f6] 'recompile)))
3+
4+
5+
(provide 'init-growl)

init-gui-frames.el

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
;;----------------------------------------------------------------------------
2+
;; Stop C-z from minimizing windows under OS X
3+
;;----------------------------------------------------------------------------
4+
(global-set-key (kbd "C-z")
5+
(lambda ()
6+
(interactive)
7+
(unless (and *is-a-mac* window-system)
8+
(suspend-frame))))
9+
10+
11+
;;----------------------------------------------------------------------------
12+
;; Suppress GUI features
13+
;;----------------------------------------------------------------------------
14+
(setq use-file-dialog nil)
15+
(setq use-dialog-box nil)
16+
(setq inhibit-startup-screen t)
17+
18+
19+
;;----------------------------------------------------------------------------
20+
;; Show a marker in the left fringe for lines not in the buffer
21+
;;----------------------------------------------------------------------------
22+
(setq default-indicate-empty-lines t)
23+
24+
25+
;;----------------------------------------------------------------------------
26+
;; Window size and features
27+
;;----------------------------------------------------------------------------
28+
(tool-bar-mode -1)
29+
(scroll-bar-mode -1)
30+
(set-fringe-mode 1)
31+
32+
(require 'init-maxframe)
33+
34+
(defun adjust-opacity (frame incr)
35+
(let* ((oldalpha (or (frame-parameter frame 'alpha) 100))
36+
(newalpha (+ incr oldalpha)))
37+
(when (and (<= frame-alpha-lower-limit newalpha) (>= 100 newalpha))
38+
(modify-frame-parameters frame (list (cons 'alpha newalpha))))))
39+
40+
(when (fboundp 'ns-toggle-fullscreen)
41+
;; Command-Option-f to toggle fullscreen mode
42+
(global-set-key (kbd "M-ƒ") 'ns-toggle-fullscreen))
43+
44+
(global-set-key (kbd "C-8") '(lambda () (interactive) (adjust-opacity nil -5)))
45+
(global-set-key (kbd "C-9") '(lambda () (interactive) (adjust-opacity nil 5)))
46+
(global-set-key (kbd "C-0") '(lambda () (interactive) (modify-frame-parameters nil `((alpha . 100)))))
47+
48+
(add-hook 'after-make-frame-functions
49+
(lambda (frame)
50+
(let ((prev-frame (selected-frame)))
51+
(select-frame frame)
52+
(prog1
53+
(unless window-system
54+
(set-frame-parameter frame 'menu-bar-lines 0))
55+
(select-frame prev-frame)))))
56+
57+
58+
59+
60+
(provide 'init-gui-frames)

init-hippie-expand.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(global-set-key (kbd "M-/") 'hippie-expand)
2+
3+
(setq hippie-expand-try-functions-list
4+
'(try-complete-file-name-partially
5+
try-complete-file-name
6+
try-expand-dabbrev
7+
try-expand-dabbrev-all-buffers
8+
try-expand-dabbrev-from-kill))
9+
10+
(provide 'init-hippie-expand)

init-htmlize.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(dolist (sym
2+
(list 'htmlize-file 'htmlize-region 'htmlize-buffer
3+
'htmlize-many-files 'htmlize-many-files-dired))
4+
(autoload sym "htmlize"))
5+
6+
7+
(provide 'init-htmlize)

0 commit comments

Comments
 (0)