Skip to content

Commit

Permalink
Some init.el cleanup
Browse files Browse the repository at this point in the history
  * move defuns to defuns.el
  * move key bindings to key-bindings.el
  * gather emacs power tools enablers
  • Loading branch information
magnars committed Oct 19, 2011
1 parent 2123a3f commit 6e349d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
15 changes: 15 additions & 0 deletions defuns.el
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ Symbols matching the text at point are put first in the completion list."

;; Other

(defun create-scratch-buffer nil
"create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
(interactive)
(let ((n 0)
bufname)
(while (progn
(setq bufname (concat "*scratch"
(if (= n 0) "" (int-to-string n))
"*"))
(setq n (1+ n))
(get-buffer bufname)))
(switch-to-buffer (get-buffer-create bufname))
(if (= n 1) (lisp-interaction-mode)) ; 1, because n was incremented
))

(defun eval-and-replace ()
"Replace the preceding sexp with its value."
(interactive)
Expand Down
43 changes: 7 additions & 36 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,6 @@
;; Lines should be 80 characters wide, not 72
(setq fill-column 80)

(defun comment-or-uncomment-and-indent-region ()
"Comments or uncomments a region and re-indents"
(interactive)
(comment-or-uncomment-region (mark) (point))
(indent-region (mark) (point))
)

;; Scratch buffers
(defun create-scratch-buffer nil
"create a new scratch buffer to work in. (could be *scratch* - *scratchX*)"
(interactive)
(let ((n 0)
bufname)
(while (progn
(setq bufname (concat "*scratch"
(if (= n 0) "" (int-to-string n))
"*"))
(setq n (1+ n))
(get-buffer bufname)))
(switch-to-buffer (get-buffer-create bufname))
(if (= n 1) (lisp-interaction-mode)) ; 1, because n was incremented
))

(global-set-key (kbd "C-c b") 'create-scratch-buffer)

;; Auto refresh buffers
(global-auto-revert-mode)

Expand All @@ -53,8 +28,6 @@
(setq backup-directory-alist `(("." . ,(expand-file-name
(concat dotfiles-dir "backups")))))

;; (setq make-backup-files nil)

;; Interactively Do Things
(require 'ido)

Expand All @@ -75,11 +48,6 @@
;; Save a list of recent files visited.
(recentf-mode 1)

;;
(set-default 'indent-tabs-mode nil)
(set-default 'indicate-empty-lines t)
(set-default 'imenu-auto-rescan t)

;; Fill text always
(add-hook 'text-mode-hook 'turn-on-auto-fill)

Expand All @@ -94,6 +62,9 @@
(delete 'try-expand-list hippie-expand-try-functions-list)

;; Misc
(set-default 'indent-tabs-mode nil)
(set-default 'indicate-empty-lines t)
(set-default 'imenu-auto-rescan t)
(mouse-wheel-mode t)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
Expand Down Expand Up @@ -142,7 +113,11 @@
(require 'key-bindings)
(require 'mac)
(require 'magit)
(require 'recall-position)

;; Run at full power please
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)

;; Ido
(custom-set-variables
Expand All @@ -154,10 +129,6 @@
'(ido-use-filename-at-point nil)
'(safe-local-variable-values (quote ((encoding . utf-8)))))

;; Recall position
(require 'recall-position)
(global-set-key (kbd "C-c C-s") 'toggle-buffer-pos)

;; Emacs server
(require 'server)
(unless (server-running-p)
Expand Down
6 changes: 6 additions & 0 deletions key-bindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@
;; Eval buffer
(global-set-key (kbd "C-c v") 'eval-buffer)

;; Create scratch buffer
(global-set-key (kbd "C-c b") 'create-scratch-buffer)

;; Move windows, even in org-mode
(global-set-key (kbd "<s-right>") 'windmove-right)
(global-set-key (kbd "<s-left>") 'windmove-left)
(global-set-key (kbd "<s-up>") 'windmove-up)
(global-set-key (kbd "<s-down>") 'windmove-down)

;; Recall position
(global-set-key (kbd "C-c C-s") 'toggle-buffer-pos)

;; Mark all
(global-set-key (kbd "C-c a") 'mark-whole-buffer)

Expand Down

0 comments on commit 6e349d4

Please sign in to comment.