2021-08-17 11:49:19 +00:00
|
|
|
;;; init-windows.el --- Window/Buffer Configuration File -*- lexical-binding: t -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
|
2023-05-19 11:09:57 +00:00
|
|
|
(use-feature emacs
|
2022-08-11 13:43:36 +00:00
|
|
|
:custom
|
|
|
|
(switch-to-buffer-obey-display-actions t)
|
2021-08-18 14:07:44 +00:00
|
|
|
:bind
|
|
|
|
("C-x C-M-b" . ibuffer)
|
2021-08-17 11:49:19 +00:00
|
|
|
: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))
|
|
|
|
|
2023-05-19 11:09:57 +00:00
|
|
|
(use-feature winner
|
2022-08-30 11:53:46 +00:00
|
|
|
:defer 5
|
2022-08-18 14:03:31 +00:00
|
|
|
: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)))
|
2021-08-17 11:49:19 +00:00
|
|
|
|
2023-05-19 11:09:57 +00:00
|
|
|
(use-feature windmove
|
2023-05-18 15:05:43 +00:00
|
|
|
:defer 5
|
|
|
|
:config (windmove-default-keybindings))
|
2021-08-17 11:49:19 +00:00
|
|
|
|
|
|
|
(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)))
|
|
|
|
|
2022-10-10 15:28:16 +00:00
|
|
|
(use-feature uniquify
|
2021-08-23 16:01:31 +00:00
|
|
|
:custom
|
|
|
|
(uniquify-buffer-name-style 'forward))
|
|
|
|
|
2021-08-17 11:49:19 +00:00
|
|
|
(use-package fullframe
|
2022-10-05 19:11:01 +00:00
|
|
|
:defer 8
|
2021-08-17 11:49:19 +00:00
|
|
|
:config
|
2022-10-05 19:11:01 +00:00
|
|
|
(fullframe magit-status magit-mode-bury-buffer)
|
2021-08-19 13:31:52 +00:00
|
|
|
(fullframe vc-annotate quit-window))
|
2021-08-17 11:49:19 +00:00
|
|
|
|
|
|
|
(use-package ace-window
|
|
|
|
:diminish
|
2023-01-06 16:16:36 +00:00
|
|
|
:config
|
|
|
|
(defun ace-window-always-dispatch (arg)
|
|
|
|
"Call `ace-window' with `aw-dispatch-always' set to t, passing through `ARG'."
|
|
|
|
(interactive "p")
|
|
|
|
(let ((aw-dispatch-always t))
|
|
|
|
(ace-window arg)))
|
2021-08-18 14:07:44 +00:00
|
|
|
:bind
|
|
|
|
([remap other-window] . ace-window)
|
2023-01-06 16:16:36 +00:00
|
|
|
("C-x O" . ace-window-always-dispatch)
|
|
|
|
:custom
|
|
|
|
(aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
|
2021-08-17 11:49:19 +00:00
|
|
|
:custom-face
|
|
|
|
(aw-leading-char-face
|
|
|
|
((t (:foreground "white" :background "red"
|
|
|
|
:weight bold :height 2.5 :box (:line-width 10 :color "red"))))))
|
|
|
|
|
2022-08-26 15:04:11 +00:00
|
|
|
(use-package popper
|
2022-10-18 15:30:50 +00:00
|
|
|
:bind (("M-`" . popper-toggle-latest)
|
|
|
|
("M-¬" . popper-cycle)
|
|
|
|
("C-`" . popper-toggle-type))
|
2022-10-12 15:45:41 +00:00
|
|
|
:custom
|
|
|
|
(popper-reference-buffers
|
|
|
|
'("\\*Messages\\*"
|
|
|
|
"\\*HTTP Response\\*"
|
|
|
|
"Output\\*$"
|
|
|
|
"\\*Async Shell Command\\*"
|
|
|
|
help-mode
|
|
|
|
helpful-mode
|
|
|
|
compilation-mode))
|
2023-05-19 11:09:57 +00:00
|
|
|
:hook (elpaca-after-init . (lambda ()
|
|
|
|
(popper-mode +1)
|
|
|
|
(popper-echo-mode +1))))
|
2021-08-17 11:49:19 +00:00
|
|
|
|
2022-10-21 15:54:28 +00:00
|
|
|
(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)))))))
|
2022-10-24 20:04:43 +00:00
|
|
|
|
|
|
|
(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)
|
2022-10-25 05:46:49 +00:00
|
|
|
"Check if BUFFER is in the buffer-ring, falling back to persp + major mode."
|
2022-10-21 15:54:28 +00:00
|
|
|
(let* ((bfr-ring (buffer-ring-current-ring))
|
|
|
|
(ring (buffer-ring-ring-ring bfr-ring)))
|
|
|
|
(if (dynaring-empty-p ring)
|
2022-10-24 20:04:43 +00:00
|
|
|
(frog-jump-buffer-filter-same-mode-in-persp buffer)
|
2022-10-21 15:54:28 +00:00
|
|
|
(frog-jump-buffer-filter-buffer-ring buffer))))
|
2022-10-24 20:04:43 +00:00
|
|
|
|
2022-10-21 15:54:28 +00:00
|
|
|
(set-face-background 'frog-menu-posframe-background-face "black")
|
2022-10-24 20:04:43 +00:00
|
|
|
|
|
|
|
(setq frog-jump-buffer-include-current-buffer nil
|
|
|
|
frog-jump-buffer-default-filter 'frog-jump-buffer-filter-persp-buffer-ring-or-same-mode
|
2022-10-25 15:37:47 +00:00
|
|
|
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)))
|
2022-10-21 15:54:28 +00:00
|
|
|
:bind
|
|
|
|
("C-," . frog-jump-buffer)
|
|
|
|
("C-x 4 C-," . frog-jump-buffer-other-window))
|
|
|
|
|
|
|
|
(use-package buffer-ring
|
|
|
|
:diminish
|
2022-10-24 20:04:43 +00:00
|
|
|
: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
|
2023-05-19 11:09:57 +00:00
|
|
|
(elpaca-after-init . buffer-ring-mode)
|
2022-10-24 20:04:43 +00:00
|
|
|
(persp-created . persp-buffer-ring-create-and-switch)
|
|
|
|
(persp-switch . persp-buffer-ring-switch)
|
2022-10-21 15:54:28 +00:00
|
|
|
:bind
|
2022-10-24 20:04:43 +00:00
|
|
|
(: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)))
|
2022-10-21 15:54:28 +00:00
|
|
|
|
|
|
|
(use-package buffer-flip
|
2023-01-17 13:19:08 +00:00
|
|
|
:custom (buffer-flip-skip-patterns '("^[*]"))
|
|
|
|
:config
|
|
|
|
;; (defun persp-buffer-flip-skip-buffer (orig &rest args)
|
|
|
|
;; (or (apply orig args)
|
|
|
|
;; (persp-buffer-filter (car args))))
|
|
|
|
;; (advice-add 'buffer-flip-skip-buffer :around 'persp-buffer-flip-skip-buffer)
|
|
|
|
(defun persp-buffer-flip-skip-buffer (orig-val)
|
|
|
|
(or orig-val (persp-buffer-filter (car args))))
|
|
|
|
(advice-add 'buffer-flip-skip-buffer :filter-return 'persp-buffer-flip-skip-buffer)
|
2022-10-21 15:54:28 +00:00
|
|
|
: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))))
|
|
|
|
|
2023-01-17 13:19:08 +00:00
|
|
|
(use-package iflipb
|
|
|
|
:config
|
|
|
|
(defun iflipb-persp-buffer-list ()
|
|
|
|
"Buffer list for iflipb."
|
|
|
|
(seq-filter 'buffer-live-p (persp-current-buffers* t)))
|
|
|
|
(dolist (cmd '(iflipb-previous-buffer iflipb-next-buffer))
|
|
|
|
(put cmd 'repeat-map 'iflipb-repeat-map))
|
|
|
|
:custom (iflipb-buffer-list-function 'iflipb-persp-buffer-list)
|
|
|
|
:bind
|
|
|
|
("C-x k" . iflipb-kill-buffer) ;; TODO replace with a kill currently selected buffer command
|
|
|
|
("<f12>" . iflipb-previous-buffer)
|
|
|
|
("<f11>" . iflipb-next-buffer))
|
|
|
|
|
2021-08-17 11:49:19 +00:00
|
|
|
(provide 'init-windows)
|
|
|
|
;;; init-windows.el ends here
|