blob: 7ce27b56cbc2bb2462bcda168cdd43b3f0b8f45e (
plain) (
blame)
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
|
;;; init-windows.el --- Window/Buffer Configuration File -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(use-package emacs
:custom
(switch-to-buffer-obey-display-actions t)
:bind
("C-x C-M-b" . ibuffer)
:config
;; From EmacsWiki
(defun toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(define-key ctl-x-4-map "t" 'toggle-window-split))
(use-package winner
:defer 5
:config
(winner-mode +1)
(defvar winner-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<left>") #'winner-undo)
(define-key map (kbd "<right>") #'winner-redo)
map))
(dolist (cmd '(winner-undo winner-redo))
(put cmd 'repeat-map 'winner-repeat-map)))
(use-package windmove
:init (windmove-default-keybindings))
(use-package buffer-move
:bind (("C-S-<up>" . buf-move-up)
("C-S-<down>" . buf-move-down)
("C-S-<left>" . buf-move-left)
("C-S-<right>" . buf-move-right)))
(use-feature uniquify
:custom
(uniquify-buffer-name-style 'forward))
(use-package fullframe
:defer 8
:config
(fullframe magit-status magit-mode-bury-buffer)
(fullframe vc-annotate quit-window))
(use-package ace-window
:diminish
:bind
([remap other-window] . ace-window)
("C-<tab>" . ace-window)
:custom-face
(aw-leading-char-face
((t (:foreground "white" :background "red"
:weight bold :height 2.5 :box (:line-width 10 :color "red"))))))
(use-package popper
:bind (("M-`" . popper-toggle-latest)
("M-¬" . popper-cycle)
("C-`" . popper-toggle-type))
:custom
(popper-reference-buffers
'("\\*Messages\\*"
"\\*HTTP Response\\*"
"Output\\*$"
"\\*Async Shell Command\\*"
help-mode
helpful-mode
compilation-mode))
:hook (emacs-startup . (lambda ()
(popper-mode +1)
(popper-echo-mode +1))))
(use-package frog-jump-buffer
:config
(defun frog-jump-buffer-filter-buffer-ring (buffer)
"Check if a BUFFER is in current buffer ring."
(let ((bfr-ring (buffer-ring-current-ring)))
(when bfr-ring
(let ((ring (buffer-ring-ring-ring bfr-ring)))
(unless (dynaring-empty-p ring)
(dynaring-contains-p ring (buffer-ring--parse-buffer buffer)))))))
(defun frog-jump-buffer-filter-same-mode-in-persp (buffer)
"Check if a BUFFER is the same as the current major mode and perspective."
(let ((current-mode major-mode))
(and
(with-current-buffer buffer
(eq major-mode current-mode))
(persp-is-current-buffer buffer))))
(defun frog-jump-buffer-filter-persp-buffer-ring-or-same-mode (buffer)
"Check if BUFFER is in the buffer-ring, falling back to persp + major mode."
(let* ((bfr-ring (buffer-ring-current-ring))
(ring (buffer-ring-ring-ring bfr-ring)))
(if (dynaring-empty-p ring)
(frog-jump-buffer-filter-same-mode-in-persp buffer)
(frog-jump-buffer-filter-buffer-ring buffer))))
(set-face-background 'frog-menu-posframe-background-face "black")
(setq frog-jump-buffer-include-current-buffer nil
frog-jump-buffer-default-filter 'frog-jump-buffer-filter-persp-buffer-ring-or-same-mode
frog-jump-buffer-use-default-filter-actions nil
frog-jump-buffer-filter-actions '(("A" "[all]" frog-jump-buffer-filter-all)
("M" "[mode]" frog-jump-buffer-filter-same-mode-in-persp)
("F" "[files]" frog-jump-buffer-filter-file-buffers)
("R" "[recentf]" frog-jump-buffer-filter-recentf) ;; TODO filter/replace frog-jump-buffer-recentf-buffers
("B" "[ring]" frog-jump-buffer-filter-buffer-ring)
("P" "[project]" frog-jump-buffer-filter-same-project)
("S" "[similar]" frog-jump-buffer-filter-similar-name)))
:bind
("C-," . frog-jump-buffer)
("C-x 4 C-," . frog-jump-buffer-other-window))
(use-package buffer-ring
:diminish
:config
(defun persp-buffer-ring-create-and-switch ()
"Create and switch to the buffer-ring for the current perspective."
;; Creating a ring automatically switches to it
(buffer-ring-torus--create-ring (persp-current-name)))
(defun persp-buffer-ring-switch ()
"Switch to the buffer-ring for the current perspective."
(buffer-ring-torus-switch-to-ring (persp-current-name)))
;; This is mostly just a convenience, to stop buffer-ring from prompting for the ring to use
(defun persp-buffer-ring-add-buffer ()
"Add the current buffer to ring for the current perspective."
(interactive)
(let ((inhibit-message t))
(buffer-ring-add (persp-current-name))))
:hook
(emacs-startup . buffer-ring-mode)
(persp-created . persp-buffer-ring-create-and-switch)
(persp-switch . persp-buffer-ring-switch)
:bind
(:map buffer-ring-mode-map
("C-c C-b a" . persp-buffer-ring-add-buffer)
("C-<" . buffer-ring-prev-buffer)
("C->" . buffer-ring-next-buffer)))
(use-package cbm
:config
(defvar cbm-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<") #'cbm-cycle)
map))
(put 'cbm-cycle 'repeat-map 'cbm-repeat-map)
:bind
("C-c C-b <" . cbm-cycle)
("C-c C-b C-b" . cbm-switch-buffer))
(use-package buffer-flip
:bind (("C-c C-<left>" . buffer-flip)
(:map buffer-flip-map
( "C-<left>" . buffer-flip-forward)
( "C-<right>" . buffer-flip-backward)
( "C-g" . buffer-flip-abort))))
(provide 'init-windows)
;;; init-windows.el ends here
|