forked from redguardtoo/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract remaining config blocks in init.el into separate init files b…
…y topic
- Loading branch information
Showing
42 changed files
with
807 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.