From 2d2cab9d97d3e84e5b7158181523fe2c5bbffe85 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 16 Apr 2023 17:06:41 -0500 Subject: uhhh --- basics.el | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'basics.el') diff --git a/basics.el b/basics.el index 3905003..15831d3 100644 --- a/basics.el +++ b/basics.el @@ -192,7 +192,7 @@ auto-save-interval 1 auto-save-no-message t auto-save-timeout 1 - auto-save-visited-interval 1 + auto-save-visited-interval 10 remote-file-name-inhibit-auto-save-visited t) (add-to-list 'auto-save-file-name-transforms `(".*" ,(etc/ "auto-save/" t) t)) @@ -208,7 +208,8 @@ (setq-default ;; recentf-save-file (etc/ "recentf" t) recentf-max-menu-items 500 recentf-max-saved-items nil ; Save the whole list - recentf-auto-cleanup 'mode) + recentf-auto-cleanup 'mode + recentf-case-fold-search t) (add-to-list 'recentf-exclude etc/) (add-to-list 'recentf-exclude "-autoloads.el\\'") (add-hook 'buffer-list-update-hook #'recentf-track-opened-file) @@ -309,13 +310,62 @@ current line." (list (line-beginning-position) (line-end-position)))))) +(defun +kill-buffer (&optional buffer-or-name) + "Kill the current buffer, or BUFFER-OR-NAME. +When called interactively, prompt the user when given a prefix +argument." + (interactive "P") + (cond + ((bufferp buffer-or-name) + (kill-buffer buffer-or-name)) + ((null buffer-or-name) + (kill-current-buffer)) + (:else + (kill-buffer (read-buffer "Kill: " nil :require-match))))) + +(defun +backward-kill-word (arg) + "Kill ARG words backward unless at the beginning of a line. +When at the beginning of a line, delete blank lines before point." + (interactive "p") + (cond + ((bolp) + ;; This is the first bit of `delete-blank-lines'. -- acdw + (let (thisblank singleblank) + (save-excursion + (beginning-of-line) + (setq thisblank (looking-at "[ \t]*$")) + ;; Set singleblank if there is just one blank line here. + (setq singleblank + (and thisblank + (not (looking-at "[ \t]*\n[ \t]*$")) + (or (bobp) + (progn (forward-line -1) + (not (looking-at "[ \t]*$"))))))) + ;; Delete preceding blank lines, and this one too if it's the only one. + (if thisblank + (progn + (beginning-of-line) + (if singleblank (forward-line 1)) + (delete-region (point) + (if (re-search-backward "[^ \t\n]" nil t) + (progn (forward-line 1) (point)) + (point-min))))) + (if (or (not thisblank) + singleblank) + (progn + (beginning-of-line) + (backward-delete-char 1))))) + (:else + (backward-kill-word arg)))) + (global-set-key [remap eval-expression] #'pp-eval-expression) (global-set-key (kbd "M-o") #'other-window|switch-buffer) (global-set-key [remap delete-window] #'delete-window|bury-buffer) (global-set-key [remap cycle-spacing] #'+cycle-spacing) -(global-set-key (kbd "C-x C-k") #'kill-this-buffer) +(global-set-key (kbd "C-x C-k") #'+kill-buffer) (global-set-key [remap comment-dwim] #'+comment-dwim) (global-set-key [remap undo] #'undo-only) +(global-set-key [remap backward-kill-word] #'+backward-kill-word) (global-set-key [f10] #'tmm-menubar) (advice-add 'tmm-add-prompt :after 'minibuffer-hide-completions) @@ -533,6 +583,12 @@ current line." ;; :preview-key (kbd "M-.") :preview-key '(:debounce 0.4 any)) + ;; (consult-customize consult-line + ;; consult-ripgrep + ;; :initial (when (use-region-p) + ;; (buffer-substring-no-properties + ;; (region-beginning) (region-end)))) + ;; Optionally configure the narrowing key. ;; Both < and C-+ work reasonably well. (setq consult-narrow-key "<") ;; (kbd "C-+") -- cgit 1.4.1-21-gabe81