(provide 'thoom-tweaks) (defun consult-buffer-other-window-no-focus () (interactive) (with-selected-window (next-window) (consult-buffer))) (defvar thoom/zoom-saved-windows nil "Variable to store the current window configuration for thoom/zoom.") (defun thoom/zoom-window () "Delete other windows, or restore the saved window configuration if available." (interactive) (if (and thoom/zoom-saved-windows (not (window-configuration-p thoom/zoom-saved-windows))) ;; Clean up if the saved config isn't valid anymore. (setq thoom/zoom-saved-windows nil)) (if thoom/zoom-saved-windows (progn (set-window-configuration thoom/zoom-saved-windows) (setq thoom/zoom-saved-windows nil)) (setq thoom/zoom-saved-windows (current-window-configuration)) (delete-other-windows))) (use-package emacs :bind (("C-c o b" . reveal-in-file-browser) ("C-o" . nil) ("C-o C-o" . other-window) ("C-o o" . other-window) ("C-o b" . consult-buffer-other-window-no-focus) ("C-o B" . consult-buffer-other-window) ("C-o /" . split-window-right) ("C-o -" . split-window-below) ("C-o C-k" . delete-window) ("C-o 1" . delete-other-windows) ("C-o w" . windmove-up) ("C-o s" . windmove-down) ("C-o a" . windmove-left) ("C-o d" . windmove-right) ;; TODO shift-wasd for moving ;; TODO C-wasd for resizing ;; TODO C-/ for undo window state change ;; TODO z for zooming ("C-o z" . thoom/zoom-window) ;; TODO other-window scrolling ("C-o n" . next-buffer) ("C-o p" . previous-buffer) :repeat-map windmove-repeat-map ("w" . windmove-up) ("a" . windmove-left) ("s" . windmove-down) ("d" . windmove-right) :repeat-map next-buffer-repeat-map ("n" . next-buffer) ("p" . previous-buffer))) (use-package dired :bind (:map dired-mode-map ("C-o" . nil) ("h" . dired-up-directory))) (use-package dirvish :ensure t :init (dirvish-override-dired-mode)) (use-package emacs :bind (("C-h C-i" . info-apropos))) ;; When scrolling by page and hitting top/bottom, move cursor to top/bottom of buffer (setq-default scroll-error-top-bottom t) ;; Revert buffers when the underlying file has changed (global-auto-revert-mode 1) ;; Remember recent files (recentf-mode 1) (setq recentf-max-menu-items 20) ;; Save what you enter into minibuffer prompts (setq history-length 25) (savehist-mode 1) ;; Visually mark the line the cursor is on (global-hl-line-mode 1) ;; Enable repeat mode. Keymaps are defined through use-package's :repeat-map directive. (repeat-mode 1) ;; Answer questions with y/n instead of yes/no (defalias 'yes-or-no-p 'y-or-n-p) ;; when opening a help window, switch focus to it unless a help window was already open (setq-default help-window-select t) ;; tabs are for monsters (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (setq-default sentence-end-double-space nil) ;; automatically cleanup whitespace on save (defun my-whitespace-cleanup () "Run `whitespace-cleanup' except for TSV files." (unless (or (derived-mode-p 'text-mode) ; Adjust this check if necessary (string-match "\\.tsv\\'" buffer-file-name)) (whitespace-cleanup))) (add-hook 'before-save-hook 'my-whitespace-cleanup) ;; clean up backup file spam (setq backup-directory-alist `(("." . "~/.saves")) delete-old-versions t kept-new-versions 4 kept-old-versions 2 version-control t) (use-package project :config ;; Make project.el recognize directories with a .project file as project roots (add-to-list 'project-vc-extra-root-markers ".project")) (use-package hl-todo :ensure t :init (global-hl-todo-mode)) (use-package which-key :ensure t :init (which-key-mode) (which-key-setup-side-window-bottom)) ;; Use right-option as regular option on Mac (setq ns-alternate-modifier 'meta) (setq ns-right-alternate-modifier 'none) (setq ns-right-command-modifier 'meta) ;; Read-only buffers activate view mode, toggle read only with C-x C-q (use-package view :init (setq view-read-only t) :bind (:map view-mode-map ("v" . View-scroll-half-page-forward) ("V" . View-scroll-half-page-backward))) (use-package direnv :ensure t :config (setq direnv-always-show-summary nil) (direnv-mode)) (use-package explain-pause-mode :ensure (:host github :repo "lastquestion/explain-pause-mode")) (defun first-executable (candidates) (seq-find #'executable-find candidates)) ;; Reveal in finder/nautilus/whatever (defun reveal-in-file-browser () (interactive) (call-process (first-executable '("xdg-open" "open")) nil nil nil "."))