emacs-dot-d/nebkor-modules/nebkor-window.el
2025-01-03 10:53:10 -08:00

75 lines
2.5 KiB
EmacsLisp

;;; General window and buffer configurations
(use-package uniquify
:ensure nil
:config
;;;; `uniquify' (unique names for buffers)
(setq uniquify-buffer-name-style 'forward)
(setq uniquify-strip-common-suffix t)
(setq uniquify-after-kill-buffer-p t))
(use-package window
:ensure nil
:config
(setq display-buffer-reuse-frames t)
(setq recenter-positions '(top middle bottom)))
;;; Frame-isolated buffers
;; Another package of mine. Read the manual:
;; <https://protesilaos.com/emacs/beframe>.
(use-package beframe
:ensure t
:hook (elpaca-after-init . beframe-mode)
:bind
("C-x f" . other-frame-prefix)
("C-c b" . beframe-prefix-map)
;; Replace the generic `buffer-menu'. With a prefix argument, this
;; commands prompts for a frame. Call the `buffer-menu' via M-x if
;; you absolutely need the global list of buffers.
("C-x C-b" . beframe-buffer-menu)
("C-x b" . beframe-switch-buffer)
("C-x B" . select-frame-by-name)
:config
(setq beframe-functions-in-frames '(project-prompt-project-dir))
(defvar consult-buffer-sources)
(declare-function consult--buffer-state "consult")
(with-eval-after-load 'consult
(defface beframe-buffer
'((t :inherit font-lock-string-face))
"Face for `consult' framed buffers.")
(defun my-beframe-buffer-names-sorted (&optional frame)
"Return the list of buffers from `beframe-buffer-names' sorted by visibility.
With optional argument FRAME, return the list of buffers of FRAME."
(beframe-buffer-names frame :sort #'beframe-buffer-sort-visibility))
(defvar beframe-consult-source
`( :name "Frame-specific buffers (current frame)"
:narrow ?F
:category buffer
:face beframe-buffer
:history beframe-history
:items ,#'my-beframe-buffer-names-sorted
:action ,#'switch-to-buffer
:state ,#'consult--buffer-state))
(add-to-list 'consult-buffer-sources 'beframe-consult-source)))
;;; Header line context of symbol/heading (breadcrumb.el)
(use-package breadcrumb
:ensure t
:functions (prot/breadcrumb-local-mode)
:hook ((text-mode prog-mode) . prot/breadcrumb-local-mode)
:config
(setq breadcrumb-project-max-length 0.5)
(setq breadcrumb-project-crumb-separator "/")
(setq breadcrumb-imenu-max-length 1.0)
(setq breadcrumb-imenu-crumb-separator " > ")
(defun prot/breadcrumb-local-mode ()
"Enable `breadcrumb-local-mode' if the buffer is visiting a file."
(when buffer-file-name
(breadcrumb-local-mode 1))))
(provide 'nebkor-window)