aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/init/ycp-buffer.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/init/ycp-buffer.el')
-rw-r--r--.emacs.d/init/ycp-buffer.el239
1 files changed, 0 insertions, 239 deletions
diff --git a/.emacs.d/init/ycp-buffer.el b/.emacs.d/init/ycp-buffer.el
deleted file mode 100644
index 56bcf08..0000000
--- a/.emacs.d/init/ycp-buffer.el
+++ /dev/null
@@ -1,239 +0,0 @@
-;;; ycp-buffer.el -- My config for buffers, windows, frames etc. -*- lexical-binding: t -*-
-
-;; Copyright (C) 2023 Free Software Foundation.
-
-;; Author: Yuchen Pei <id@ypei.org>
-;; Protesilaos Stavrou <info@protesilaos.com>
-;; Maintainer: Yuchen Pei <id@ypei.org>
-;; Package-Requires: ((emacs "28.2"))
-
-;; This file is part of dotfiles.
-
-;; dotfiles is free software: you can redistribute it and/or modify it under
-;; the terms of the GNU Affero General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; dotfiles is distributed in the hope that it will be useful, but WITHOUT
-;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
-;; Public License for more details.
-
-;; You should have received a copy of the GNU Affero General Public
-;; License along with dotfiles. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; My config for buffers, windows, frames etc..
-
-;;; Code:
-
-
-(my-package my-buffer
- (:delay 15)
- (my-keybind global-map
- "\M-c" #'my-copy-buffer-file-name
- "<C-f2>" #'my-rename-file-and-buffer
- "C-x k" #'my-kill-buffer
- "M-s b" #'my-switch-to-buffer-matching-major-mode
- "M-s v" #'my-buffers-vc-root
- ;; F7: Cycle or create buffers with the same base buffer as the
- ;; current buffer
- "<f7>" #'my-create-or-switch-indirect-buffers
- ;; F8: Cycle or create buffers with the same major mode as the
- ;; current buffer
- "<f8>" #'my-buffer-create-or-cycle-same-mode
- ;; F9: Prompt for a mode, then switch to or create a buffer of
- ;; that mode
- "<f9>" #'my-buffer-switch-or-create-major-mode
- )
- )
-
-(my-configure
- (:delay 15)
- (my-keybind ctl-x-x-map
- "f" #'follow-mode ; override `font-lock-update'
- "r" #'rename-uniquely
- "l" #'visual-line-mode)
-
- ;; make ibuffer default
- (advice-add 'list-buffers :override 'ibuffer-list-buffers)
-
- ;; In Emacs 27+, use Control + mouse wheel to scale text.
- (setq mouse-wheel-scroll-amount
- '(1
- ((shift) . 5)
- ((meta) . 0.5)
- ((control) . text-scale))
- mouse-drag-copy-region nil
- make-pointer-invisible t
- mouse-wheel-progressive-speed t
- mouse-wheel-follow-mouse t)
-
- ;; Scrolling behaviour
- (setq-default scroll-conservatively 1 ; affects `scroll-step'
- scroll-margin 0
- next-screen-context-lines 0)
-
- (mouse-wheel-mode 1)
- (define-key global-map (kbd "C-M-<mouse-3>") #'tear-off-window))
-
-;;; Repeatable key chords (repeat-mode)
-(my-package repeat
- (:delay 30)
- (setq repeat-on-final-keystroke t
- repeat-exit-timeout 5
- repeat-exit-key "<escape>"
- repeat-keep-prefix nil
- repeat-check-key t
- repeat-echo-function 'ignore
- ;; Technically, this is not in repeal.el, though it is the
- ;; same idea.
- set-mark-command-repeat-pop t)
- (repeat-mode 1))
-
-;;;; Built-in bookmarking framework (bookmark.el)
-(my-package bookmark
- (setq bookmark-use-annotations nil)
- (setq bookmark-automatically-show-annotations t)
- (add-hook 'bookmark-bmenu-mode-hook #'hl-line-mode))
-
-(my-package follow
- (:delay 15)
- ;; TODO: update this to adapt to number of windows
- (my-keybind follow-mode-map
- "C-v" #'follow-scroll-up
- "M-v" #'follow-scroll-down
- "<next>" #'follow-scroll-up
- "<prior>" #'follow-scroll-down)
- )
-
-(my-package view
- (:delay 10)
- (my-keybind view-mode-map
- "n" #'next-line
- "p" #'previous-line
- "f" #'forward-char
- "b" #'backward-char
- "e" #'move-end-of-line
- "a" #'move-beginning-of-line
- "v" #'scroll-up-command
- "V" #'scroll-down-command
- "l" #'previous-buffer
- "r" #'next-buffer
- "d" nil
- "u" nil
- "w" #'kill-ring-save
- "i" #'view-mode)
- (my-keybind global-map "C-`" #'view-mode))
-
-;; move windows
-(my-package windmove
- (:delay 5)
- (windmove-default-keybindings 'control)
- ;; swap windows
- (windmove-swap-states-default-keybindings '(control shift))
- (setq windmove-wrap-around t))
-
-(my-package winner
- (:delay 5)
- (winner-mode t))
-
-;;;; `window', `display-buffer-alist', and related
-(my-package window
- (require 'time)
- (require 'my-buffer)
- (setq display-buffer-alist
- `(;; no window
- ("\\`\\*Async Shell Command\\*\\'"
- (display-buffer-no-window)
- (dedicated . t))
- ;; bottom side window
- ("\\*Org Select\\*" ; the `org-capture' key selection
- (display-buffer-in-side-window)
- (dedicated . t)
- (side . bottom)
- (slot . 0)
- (window-parameters . ((mode-line-format . none))))
- ;; bottom buffer (NOT side window)
- ((or . (,(my-buffer-make-display-matcher
- '(flymake-diagnostics-buffer-mode
- flymake-project-diagnostics-mode
- messages-buffer-mode backtrace-mode))
- "\\*\\(Warnings\\|Compile-Log\\|Org Links\\)\\*"
- ,world-clock-buffer-name))
- (display-buffer-reuse-mode-window display-buffer-at-bottom)
- (window-height . 0.3)
- (dedicated . t)
- (preserve-size . (t . t)))
- ("\\*\\(Output\\|Register Preview\\).*"
- (display-buffer-reuse-mode-window display-buffer-at-bottom))
- ;; below current window
- ((derived-mode . help-mode) ; See the hooks for `visual-line-mode'
- (display-buffer-reuse-mode-window display-buffer-below-selected))
- ("\\*\\vc-\\(incoming\\|outgoing\\|git : \\).*"
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (window-height . 0.1)
- (dedicated . t)
- (preserve-size . (t . t)))
- ((derived-mode . log-view-mode)
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (window-height . 0.3)
- (dedicated . t)
- (preserve-size . (t . t)))
- ((derived-mode . reb-mode) ; M-x re-builder
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (window-height . 4) ; note this is literal lines, not relative
- (dedicated . t)
- (preserve-size . (t . t)))
- ("\\*\\(Calendar\\|Bookmark Annotation\\).*"
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (dedicated . t)
- (window-height . fit-window-to-buffer))
- ("\\*ispell-top-choices\\*.*"
- (display-buffer-reuse-mode-window display-buffer-below-selected)
- (window-height . fit-window-to-buffer))
- ;; same window
-
- ;; NOTE 2023-02-17: `man' does not fully obey the
- ;; `display-buffer-alist'. It works for new frames and for
- ;; `display-buffer-below-selected', but otherwise is
- ;; unpredictable. See `Man-notify-method'.
- ((or . ((derived-mode . Man-mode)
- (derived-mode . woman-mode)
- "\\*\\(Man\\|woman\\).*"
- "\\*shell\\*.*"))
- (display-buffer-same-window))
-))
-
- (setq switch-to-buffer-in-dedicated-window 'pop)
- (setq window-combination-resize t)
- (my-keybind resize-window-repeat-map
- ">" #'enlarge-window-horizontally
- "<" #'shrink-window-horizontally)
- )
-
-(my-keybind global-map
- "C-x C-n" #'next-buffer ; override `set-goal-column'
- "C-x C-p" #'previous-buffer ; override `mark-page'
- "C-x !" #'delete-other-windows-vertically
- "C-x _" #'balance-windows ; underscore
- "C-x -" #'fit-window-to-buffer ; hyphen
- "C-x +" #'balance-windows-area
- "C-x }" #'enlarge-window
- "C-x {" #'shrink-window
- "C-x >" #'enlarge-window-horizontally ; override `scroll-right'
- "C-x <" #'shrink-window-horizontally) ; override `scroll-left'
-
-(my-package my-buffer
- (:delay 10)
- (my-keybind global-map
- "<f1>" #'my-focus-write
- "<insert>" #'my-cycle-windows
- "C-M-<mouse-4>" #'my-increase-default-face-height
- "C-M-<mouse-5>" #'my-decrease-default-face-height)
- )
-
-(setq large-file-warning-threshold 15000000)
-
-(provide 'ycp-buffer)