-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy-editing.el
134 lines (109 loc) · 4.6 KB
/
my-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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
;; Turn on selection
(setq transient-mark-mode 't highlight-nonselected-windows 't)
;; Pressing backspace during an Isearch will delete the previous
;; character typed (or do a reverse isearch if something matches the
;; current word). Without this, it will delete the highlighted text.
(define-key isearch-mode-map [backspace] 'isearch-delete-char)
;; Replace highlighted/marked areas
(delete-selection-mode t)
(setq indent-tabs-mode nil)
(global-unset-key "\C-c\C-c")
(global-set-key "\C-c\C-c" 'comment-or-uncomment-region)
(global-set-key "\C-ck" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
(global-set-key "\C-w" 'backward-kill-word)
;; Deletes trailing whitespace on all lines except the current one
;; so we don't affect our current indentation, etc.
;; (defun delete-all-but-whitespace ()
;; (interactive)
;; (setq c (current-column))
;; ;; If the line is empty, we don't want to kill it (it will move our mark)
;; (setq isEmpty (or (eobp) (looking-at "\s$")))
;; ;; If we're not looking at an empty line,
;; ;; add it (and only it) to the kill ring, the delete the current line.
;; ;; This introduces a blank line, unfortunately, which is later a problem.
;; (if (not isEmpty)
;; (progn
;; (kill-new (thing-at-point 'line))
;; (delete-region (line-beginning-position) (line-end-position))
;; ))
;; (delete-trailing-whitespace)
;; (if (not isEmpty)
;; ;; Put the line back on the screen, delete the blank one, and go
;; ;; back up a row
;; (progn (yank)
;; (kill-line)
;; (previous-line)
;; (current-kill 1)))
;; (move-to-column c)
;; (setq c nil))
;; (setq delete-all-but-whitespace nil)
;; (remove-hook 'before-save-hook 'delete-all-but-whitespace)
;; Add hook so we delete whitespace every time we save.
;; (add-hook 'before-save-hook
;; (lambda ()
;; (delete-all-but-whitespace)))
(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 yank (before slick-copy activate)
"Position point when yanking lines."
(let ((kill (current-kill 0 t)))
(when (eq ?\n (elt kill (1- (length kill))))
(beginning-of-line))))
(eval-after-load "ispell"
(progn
(setq ispell-extra-args '()
ispell-silently-savep t
ispell-dictionary "american")))
(setq-default ispell-program-name "ispell")
(require 'autopair)
(add-hook 'term-mode-hook
#'(lambda () (setq autopair-dont-activate t)))
(add-hook 'c-mode-common-hook #'(lambda () (autopair-mode)))
(add-hook 'python-mode-hook #'(lambda () (autopair-mode)))
;; Major life saver --- auto-indents yanked code
(dolist (command '(yank yank-pop))
(eval `(defadvice ,command (after indent-region activate)
(and (not current-prefix-arg)
(member major-mode '(emacs-lisp-mode lisp-mode
clojure-mode scheme-mode
haskell-mode ruby-mode
rspec-mode python-mode
c-mode c++-mode
objc-mode latex-mode
plain-tex-mode))
(let ((mark-even-if-inactive transient-mark-mode))
(indent-region (region-beginning) (region-end) nil))))))
(setq compilation-skip-threshold 0)
(add-hook 'c-mode-common-hook
(lambda()
(add-hook 'write-contents-functions
(lambda()
(save-excursion
(delete-trailing-whitespace))
(indent-for-tab-command)))))
(require 'iedit)
(define-key global-map (kbd "C-;") 'iedit-mode)
(define-key isearch-mode-map (kbd "C-;") 'iedit-mode)
(global-set-key (kbd "C-M-y") 'replace-rectangle)
(require 'paredit)
(setq my-lisp-par-hook #'(lambda ()
(paredit-mode 1)
(autopair-mode -1)))
(add-hook 'lisp-mode-hook my-lisp-par-hook)
(add-hook 'emacs-lisp-mode-hook my-lisp-par-hook)
(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)
;(require 'anything)
(require 'exec-path-from-shell)
(exec-path-from-shell-initialize)
(exec-path-from-shell-copy-env "EDITOR")
(exec-path-from-shell-copy-env "PYTHONPATH")
(require 'clang-format)
(global-set-key (kbd "C-M-i") 'clang-format-region)
(provide 'my-editing)
;;; my-editing.el ends here