From f0294f7fb4de3fed7e3f14969ebaa1531193361e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Thu, 6 Jan 2022 22:55:26 -0600 Subject: Lots of other changes --- init.el | 32 ++++++++++++++++++++++++-------- lisp/acdw.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/init.el b/init.el index 970ab83..5fab995 100644 --- a/init.el +++ b/init.el @@ -37,7 +37,12 @@ "M-j" nil "C-x o" (lambda () (interactive) (switch-to-buffer nil)) "C-x C-o" #'+open-paragraph - "C-w" #'+kill-word-backward-or-region) + "C-w" #'+kill-word-backward-or-region + "C-x C-1" #'delete-other-windows + "C-x 2" #'+split-window-below-then + "C-x C-2" #'+split-window-below-then + "C-x 3" #'+split-window-right-then + "C-x C-3" #'+split-window-right-then) ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults (global-set-key (kbd "C-h") 'delete-backward-char) (keyboard-translate ?\C-h ?\C-?) @@ -741,11 +746,11 @@ (:also-load +consult) ;; from Consult wiki (:option register-preview-delay 0 - register-preview-function 'consult-register-format - xref-show-xrefs-function 'consult-xref - xref-show-definitions-function 'consult-xref + register-preview-function #'consult-register-format + xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref tab-always-indent 'complete - completion-in-region-function 'consult-completion-in-region) + completion-in-region-function #'consult-completion-in-region) (advice-add #'register-preview :override #'consult-register-window) (advice-add #'completing-read-multiple :override #'consult-completing-read-multiple) @@ -819,6 +824,12 @@ (with-eval-after-load 'orderless (:option consult--regexp-compiler 'consult--orderless-regexp-compiler)))) +(setup (:straight consult-dir) + (:+key "C-x C-d" #'consult-dir) + (:with-map vertico-map + (:bind "C-x C-d" #'consult-dir + "C-x C-j" #'consult-dir-jump-file))) + (setup (:straight crux) ;; yes it's silly I have an addon to this addon. (:also-load +crux) @@ -902,7 +913,8 @@ See also `crux-reopen-as-root-mode'." (setup (:straight elpher)) (setup (:straight embark) - (:option prefix-help-command 'embark-prefix-help-command) + (:option prefix-help-command 'embark-prefix-help-command + embark-keymap-prompter-key ";") (:+key "C-." #'embark-act "M-." #'embark-dwim " B" #'embark-bindings) @@ -1162,8 +1174,10 @@ See also `crux-reopen-as-root-mode'." (setup (:straight paredit) (:bind "DEL" #'paredit-backward-delete "C-" #'paredit-backward-kill-word - "C-w" (lambda (r) (interactive "P") - (+kill-word-backward-or-region r #'paredit-backward-kill-word))) + "C-w" (lambda (arg) (interactive "P") + (+kill-word-backward-or-region arg + #'paredit-backward-kill-word)) + "M-s" nil) (dolist (hook '(emacs-lisp-mode-hook eval-expression-minibuffer-setup-hook ielm-mode-hook @@ -1224,6 +1238,8 @@ See also `crux-reopen-as-root-mode'." (simple-modeline-mode +1)) (setup (:straight smartscan) + (:with-map smartscan-map + (:bind "M-'" nil)) (:hook-into prog-mode)) (setup (:straight (sophomore diff --git a/lisp/acdw.el b/lisp/acdw.el index 8b9c7b9..9361cdf 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -185,5 +185,55 @@ three blank lines, then place the point on the second one." (newline 2) (previous-line))) +(defun +split-window-then (&optional where arg) + "Split the window into a new buffer. +With non-nil ARG (\\[universal-argument] interactively), don't +prompt for a buffer to switch to. This function will split the +window using `split-window-sensibly', or open the new window in +the direction specified by WHERE. WHERE is ignored when called +interactively; if you want specific splitting, use +`+split-window-right-then' or `+split-window-below-then'." + (interactive "i\nP") + ;; TODO: Canceling at the switching phase leaves the point in the other + ;; window. Ideally, the user would see this as one action, meaning a cancel + ;; would return to the original window. + (pcase where + ;; These directions are 'backward' to the OG Emacs split-window commands, + ;; because by default Emacs leaves the cursor in the original window. Most + ;; users probably expect a switch to the new window, at least I do. + ((or 'right :right) (split-window-right) (other-window 1)) + ((or 'left :left) (split-window-right)) + ((or 'below :below) (split-window-below) (other-window 1)) + ((or 'above :above) (split-window-below)) + ((pred null) + (or (split-window-sensibly) + (if (< (window-height) (window-width)) + (split-window-below) + (split-window-right))) + (other-window 1)) + (_ (user-error "Unknown WHERE paramater: %s" where))) + (unless arg + (condition-case nil + (call-interactively + (pcase (read-char "(B)uffer or (F)ile?") + (?b (if (fboundp #'consult-buffer) + #'consult-buffer + #'switch-to-buffer)) + (?f #'find-file) + (_ #'ignore))) + (quit (delete-window))))) + +(defun +split-window-right-then (&optional arg) + "Split window right, then prompt for a new buffer. +With optional ARG (\\[universal-argument]), just split." + (interactive "P") + (+split-window-then :right arg)) + +(defun +split-window-below-then (&optional arg) + "Split window below, then prompt for a new buffer. +With optional ARG (\\[universal-argument]), just split." + (interactive "P") + (+split-window-then :below arg)) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81