blob: c64f271fd3c779f03c68dcd5483f0fe7f00f8712 (
plain)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
;;; Editing niceties
(use-package emacs
:bind
(("C-c r" . jump-to-register))
:config
(setq reb-re-syntax 'string))
;; writeable grep buffers
(use-package wgrep
:ensure t
:bind
(:map wgrep-mode-map
("C-x C-s" . wgrep-save-all-buffers)
("C-x C-q" . wgrep-change-to-wgrep-mode)
("C-c C-c" . wgrep-finish-edit))
:bind
(:map grep-mode-map
("e" . wgrep-change-to-wgrep-mode)))
;; preview replace
(use-package multiple-cursors
:ensure t
:config
(setq mc/always-run-for-all t)
:bind
(("C-S-c C-S-c" . mc/edit-lines)
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C" . mc/mark-all-like-this)
("C-\"". mc/skip-to-next-like-this)
("C-:" . mc/skip-to-previous-like-this)))
(use-package expand-region
:ensure t
:bind ("C-=" . er/expand-region))
(use-package substitute
:ensure t
:bind
(("C-c s b" . substitute-target-below-point)
("C-c s a" . substitute-target-above-point)
("C-c s d" . substitute-target-in-defun)
("C-c s s" . substitute-target-in-buffer)))
;; Desktop mode/session saving
(setq desktop-path '("~/.emacs.d/desktop")
desktop-dirname "~/.emacs.d/desktop/"
desktop-base-file-name "emacs-desktop"
desktop-save t
desktop-restore-eager t
desktop-restore-=frams t
desktop-restory-in-current-display t
desktop-files-not-to-save "\(^$\\|\\*scratch\\*\\|\\*Messages\\*\\|\\*dashboard\\*\\|\\*Async-native-compile-log\\*|\\*Music\\*)")
;;; General Keybinds
;; Buffer switching
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; Desktop/session save
;; (desktop-save-mode t)
(global-set-key (kbd "C-z s") 'desktop-save-in-desktop-dir)
(global-set-key (kbd "C-z r") 'desktop-read)
;;; Scratch buffers
;; Text Scratch buffers
(defun bard/new-org-buffer ()
(interactive)
(let ((xbuf (generate-new-buffer "*org*")))
(switch-to-buffer xbuf)
(funcall (quote org-mode))
(text-scale-increase 1.5)
xbuf))
(define-key global-map (kbd "M-=") #'bard/new-org-buffer)
(defun bard/new-plain-buffer ()
(interactive)
(let ((xbuf (generate-new-buffer "*plain*")))
(switch-to-buffer xbuf)
(text-scale-increase 1.5)
xbuf))
(define-key global-map (kbd "M--") #'bard/new-plain-buffer)
;; elisp scratch buffer
(defun bard/new-elisp-buffer ()
(interactive)
(let ((xbuf (generate-new-buffer "*elisp*")))
(switch-to-buffer xbuf)
(funcall (quote emacs-lisp-mode))
(text-scale-increase 1.5)
xbuf))
;;; Terminals
(defun bard/open-terminal-in-current-directory ()
"Open a terminal in the current working directory."
(interactive)
(let ((default-directory default-directory))
(term "/bin/bash")))
;; (define-key global-map (kbd "C-t") #'bard/open-terminal-in-current-directory)
(define-key global-map (kbd "C-z t") #'bard/open-terminal-in-current-directory)
(defun bard/open-terminal-emulator ()
"Open a terminal in the current working directory."
(interactive)
(let ((default-directory default-directory))
(start-process "st terminal" nil "st")))
(define-key global-map (kbd "C-z C-t") 'bard/open-terminal-emulator)
(define-key global-map (kbd "C-z C-s") #'bard/new-elisp-buffer)
;;; Time Management
;; Modeline
(setq display-time-format "%Y-%m-%d (%A) %H:%M")
(setq display-time-interval 60)
(setq display-time-default-load-average nil)
(setq display-time-mail-directory nil)
(setq display-time-mail-function nil)
(setq display-time-use-mail-icon nil)
(setq display-time-mail-string nil)
(setq display-time-mail-face nil)
(setq display-time-string-forms
'((propertize
(format-time-string display-time-format now)
'face 'display-time-date-and-time
'help-echo (format-time-string "%a %b %e, %Y" now))
" "))
(display-time-mode 1)
;; world clock
(setq world-clock-list
'(("America/New_York" "New York")
("Europe/Moscow" "Moscow")
("Europe/London" "London")
("Asia/Tokyo" "Tokyo")))
(setq world-clock-time-format "%Y-%m-%d %B (%A) %R %Z")
(define-key global-map (kbd "C-c C-w") #'world-clock)
(use-package breadcrumb
:ensure t
:hook
(prog-mode . breadcrumb-local-mode))
(use-package vundo
:ensure t
:defer 1
:bind
( :map vundo-mode-map
("C-/" . vundo-backward)
("C-?" . vundo-forward)
("g" . vundo-goto-last-saved)
("p" . vundo-backward)
("n" . vundo-forward)
("f" . vundo-next)
("b" . vundo-previous))
:config
(setq vundo-glyph-alist vundo-unicode-symbols)
(defvar prot/vundo-undo-functions '(undo undo-only undo-redo)
"List of undo functions to check if we need to visualise the undo ring.")
(defvar prot/vundo-undo-command #'undo
"Command to call if we are not going to visualise the undo ring.")
(defun prot/vundo-if-repeat-undo (&rest args)
"Use `vundo' if the last command is among `prot/vundo-undo-functions'.
In other words, start visualising the undo ring if we are going
to be cycling through the edits."
(interactive)
(if (and (member last-command prot/vundo-undo-functions)
(not undo-in-region))
(call-interactively 'vundo)
(apply args)))
(mapc
(lambda (fn)
(advice-add fn :around #'prot/vundo-if-repeat-undo))
prot/vundo-undo-functions))
;; running emacs as server
(require 'server)
(setq server-client-instructions nil)
(unless (server-running-p)
(server-start))
(provide 'bard-emacs-essentials)
|