From 4163eb4053cde10b64b2cfe6d9782be27fd50faf Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Wed, 24 Aug 2022 13:40:59 +0700 Subject: [PATCH] Bankrupt: Better buffer management, vertico tweaks, unbind company --- .emacs.bankruptcy/init.org | 54 +++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/.emacs.bankruptcy/init.org b/.emacs.bankruptcy/init.org index 578f9de..0e58185 100644 --- a/.emacs.bankruptcy/init.org +++ b/.emacs.bankruptcy/init.org @@ -147,10 +147,6 @@ This avoids those annoying *#backup#* files that get added and eventually slow d kept-new-versions 6 kept-old-versions 2 version-control t) - -(global-set-key (kbd "C-x k") #'kill-this-buffer) -(global-set-key (kbd "C-x M-k") #'kill-buffer) - #+END_SRC ** Visuals *** Dashboard @@ -265,6 +261,37 @@ Setup other stuff (add-hook 'before-save-hook 'whitespace-cleanup) #+end_src +** Buffers +#+begin_src emacs-lisp +(global-set-key (kbd "C-x k") #'kill-this-buffer) +(global-set-key (kbd "C-x M-k") #'kill-buffer) +(straight-use-package 'all-the-icons-ibuffer) +(add-hook 'ibuffer-mode-hook #'all-the-icons-ibuffer-mode) +(global-set-key [remap list-buffers] 'ibuffer) +(global-set-key (kbd "C-x B") 'ibuffer) +(global-set-key (kbd "C-x C-b") 'switch-to-buffer) + +(defun joe/switch-other-buffer () + "Switch to other buffer" + (interactive) + (switch-to-buffer (other-buffer))) + +(global-set-key (kbd "C-x b") 'joe/switch-other-buffer) +#+end_src + +The theme of `C-x 4` bindings is that they operate on other windows, so this function matches that behavior. + +#+begin_src emacs-lisp +(defun joe/kill-other-buffer-and-window () + "Kill other buffer and window" + (interactive) + (other-window 1) + (kill-buffer-and-window)) +(global-set-key (kbd "C-x 4 0") 'joe/kill-other-buffer-and-window) +(global-set-key (kbd "C-x C-0") 'kill-buffer-and-window) + +#+end_src + ** Org Mode #+begin_src emacs-lisp (straight-use-package 'org-bullets) @@ -287,12 +314,17 @@ Vertico Embark Marginalia Consult Orderless (require 'all-the-icons) (straight-use-package 'all-the-icons-completion) -(straight-use-package '(vertico :files (:defaults "extensions/*") :includes (vertico-directory))) +(straight-use-package '(vertico :files (:defaults "extensions/*") :includes (vertico-directory vertico-reverse))) ;; :bind (:map vertico-map ;; ("\M-G" . vertico-multiform-mode) ;; ("\M-e" . embark-act))) (vertico-mode) +(vertico-reverse-mode) +(setq vertico-count 17 + vertico-resize t + vertico-cycle t) + (require 'savehist) (savehist-mode) (straight-use-package 'vertico-directory) @@ -326,7 +358,7 @@ Vertico Embark Marginalia Consult Orderless (global-set-key (kbd "C-h f") #'helpful-callable) (global-set-key (kbd "C-h v") #'helpful-variable) (global-set-key (kbd "C-h k") #'helpful-key) -(global-set-key (kbd "C-c C-d") #'helpful-at-point) +(global-set-key (kbd "C-h C-d") #'helpful-at-point) (global-set-key (kbd "C-h F") #'helpful-function) (global-set-key (kbd "C-h C") #'helpful-command) #+end_src @@ -369,7 +401,7 @@ Vertico Embark Marginalia Consult Orderless (define-key global-map (kbd "C-c t t") #'multi-vterm) (define-key global-map (kbd "C-c t p") #'multi-vterm-prev) (define-key global-map (kbd "C-c t n") #'multi-vterm-next) - +(add-hook 'vterm-mode-hook (lambda () (setq-local global-hl-line-mode nil))) #+end_src ** Undo Tree @@ -584,8 +616,8 @@ Emacs is an great operating system, if only it had a good text editor... ;; (add-to-list 'completion-at-point-functions #'cape-symbol) ;; (add-to-list 'completion-at-point-functions #'cape-file) ;; (add-to-list 'completion-at-point-functions #'cape-dabbrev) -;; (straight-use-package 'kind-icon) -;; (require 'kind-icon) +(straight-use-package 'kind-icon) +(require 'kind-icon) (straight-use-package 'company) (require 'company) @@ -595,11 +627,13 @@ Emacs is an great operating system, if only it had a good text editor... company-frontends '(company-preview-frontend company-echo-metadata-frontend) ;; company-frontends '(company-text-icons-margin company-echo-metadata-frontend) company-backends '((company-capf company-files))) - (setq company-transformers '(company-sort-by-occurrence)) ;; (setq company-transformers '()) (add-to-list 'completion-at-point-functions #'elisp-completion-at-point) (with-eval-after-load 'company + (define-key company-active-map (kbd "C-n") nil) + (define-key company-active-map (kbd "C-p") nil) + (define-key company-active-map (kbd "RET") nil) (define-key company-active-map (kbd "C-f") #'company-complete-selection) (define-key company-active-map [tab] #'company-complete-common-or-cycle) (define-key company-active-map (kbd "") (lambda () (interactive) (company-complete-common-or-cycle -1))))