This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
init-editing.el
89 lines (71 loc) · 2.83 KB
/
init-editing.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
;;; general editing configuration
;; Turn off mouse interface early in startup to avoid momentary flash
;; of things I don't want.
(progn
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode))
(when (fboundp mode) (funcall mode -1))))
;; Don't show the splash screen
(setq inhibit-startup-screen t
;; Show the *scratch* on startup
initial-buffer-choice t)
;; I got sick of typing "yes"
(defalias 'yes-or-no-p 'y-or-n-p)
;; I prefer spaces over tabs
(setq-default
indent-tabs-mode nil
;; ... and I prefer 4-space indents
tab-width 4)
;; UTF-8 please!
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; Don't clobber things in the system clipboard when killing
(setq save-interprogram-paste-before-kill t)
;; nuke trailing whitespace when writing to a file
(add-hook 'write-file-hooks 'delete-trailing-whitespace)
;; always add a trailing newline - it's POSIX
(setq require-final-newline t)
;; http://emacs-fu.blogspot.hk/2009/11/copying-lines-without-selecting-them.html
(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))
(list (line-beginning-position)
(line-beginning-position 2)))))
;; smart beginning-of-line, from:
;; http://irreal.org/blog/?p=1946
(defadvice move-beginning-of-line (around smarter-bol activate)
;; Move to requested line if needed.
(let ((arg (or (ad-get-arg 0) 1)))
(when (/= arg 1)
(forward-line (1- arg))))
;; Move to indentation on first call, then to actual BOL on second.
(let ((pos (point)))
(back-to-indentation)
(when (= pos (point))
ad-do-it)))
;; enable hl-line-mode for prog-mode
(add-hook 'prog-mode-hook 'bw-enable-hl-line-mode)
;; turn on electric-indent-mode
(add-hook 'prog-mode-hook 'bw/turn-on-electric-indent-mode)
;; I want to use narrowing
(put 'narrow-to-defun 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
;; I want to use scrolling
(put 'scroll-left 'disabled nil)
;; Make rectangle selection better
(cua-selection-mode 1)
;; stop allowing point over minibuffer prompt
;; http://ergoemacs.org/emacs/emacs_stop_cursor_enter_prompt.html
(setq minibuffer-prompt-properties (add-to-list 'minibuffer-prompt-properties 'minibuffer-avoid-prompt))
(setq minibuffer-prompt-properties (add-to-list 'minibuffer-prompt-properties 'point-entered))
(provide 'init-editing)