From 71d22a41dbd1d9f152ca865e671293a435465759 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 20 Aug 2021 07:57:35 -0500 Subject: A couple o' changes --- init.el | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/init.el b/init.el index 0ffe042..20010d1 100644 --- a/init.el +++ b/init.el @@ -536,15 +536,20 @@ like a dumbass." ("web" (or (mode . elpher-mode) (mode . gemini-mode) (mode . eww-mode)))))) - (:global "C-x C-b" ibuffer) - (add-hook 'ibuffer-mode - (defun ibuffer@filter-to-default () - (ibuffer-switch-to-saved-filter-groups "default"))) + (global-set-key (kbd "C-x C-b") + (defun list-buffers-or-ibuffer (arg) + "`list-buffers', or with a prefix arg, `ibuffer'." + (interactive "P") + (if arg (ibuffer) (electric-buffer-list nil))))) - (:also-load ibuf-ext) - (:option ibuffer-show-empty-filter-groups nil - ibuffer-expert t)) +(add-hook 'ibuffer-mode + (defun ibuffer@filter-to-default () + (ibuffer-switch-to-saved-filter-groups "default"))) + +(:also-load ibuf-ext) +(:option ibuffer-show-empty-filter-groups nil + ibuffer-expert t)) (setup imenu (:option imenu-auto-rescan t)) @@ -938,6 +943,41 @@ like a dumbass." (:bind "M-e" consult-isearch "M-s e" consult-isearch "M-s l" consult-line)) + + ;; see https://github.com/oantolin/completing-history + (defmacro consult-history-to-modes (map-hook-alist) + (let (defuns) + (dolist (map-hook map-hook-alist) + (let ((map-name (symbol-name (car map-hook))) + (key-defs `(progn (define-key + ,(car map-hook) + (kbd "M-r") + (function consult-history)) + (define-key ,(car map-hook) + (kbd "M-s") nil)))) + (push (if (cdr map-hook) + `(add-hook ',(cdr map-hook) + (defun + ,(intern (concat map-name + "@consult-history-bind")) + nil + ,(concat + "Bind `consult-history' to M-r in " + map-name ".\n" + "Defined by `consult-history-to-modes'.") + ,key-defs)) + key-defs) + defuns))) + `(progn ,@ (nreverse defuns)))) + + (consult-history-to-modes ((minibuffer-local-map . nil) + (shell-mode-map . shell-mode-hook) + (term-mode-map . term-mode-hook) + (term-raw-map . term-mode-hook) + (comint-mode-map . comint-mode-hook) + (sly-mrepl-mode-map . sly-mrepl-hook))) + + ;; Registers (autoload 'consult-register-preview "consult") @@ -1131,6 +1171,10 @@ successive invocations." (setup (:straight form-feed) (global-form-feed-mode +1)) +(setup (:straight gcmh) + (:option gcmh-idle-delay 'auto) + (gcmh-mode +1)) + (setup (:straight geiser)) (setup (:straight (gemini-mode @@ -1161,7 +1205,12 @@ successive invocations." " k" helpful-key " o" helpful-symbol "C-c C-d" helpful-at-point) - (:bind "q" kill-buffer-and-window)) + (define-key helpful-mode-map "q" + (defun helpful-mode|quit () + (interactive) + (bury-buffer) + (unless (window-parameter (frame-selected-window) 'no-other-window) + (delete-window))))) (setup (:straight iscroll) (:hook-into text-mode)) @@ -1500,7 +1549,16 @@ successive invocations." (:option resize-mini-windows 'grow-only vertico-count-format nil vertico-cycle t) - + + (defun up-directory (arg) + "Move up a directory (delete backwards to /)." + (interactive "p") + (if (string-match-p "/." (minibuffer-contents)) + (zap-up-to-char (- arg) ?/) + (backward-kill-word arg))) + + (define-key vertico-map (kbd "") #'up-directory) + (if (boundp 'comp-deferred-compilation-deny-list) (add-to-list 'comp-deferred-compilation-deny-list "vertico")) -- cgit 1.4.1-21-gabe81