From 30cd6555bfa43e792eaac5ae32e39d7cafa5a3e2 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 25 Dec 2021 01:25:25 -0600 Subject: Bunch of changes; notably +filldent-dwim I might add this into filldent.el as `filldent-stupidly', later. --- init.el | 12 +----------- lisp/+emacs.el | 49 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/init.el b/init.el index e8dd1c9..86dca9a 100644 --- a/init.el +++ b/init.el @@ -108,6 +108,7 @@ "imgur.com" "pixelfed" "instagram.com" "bibliogram.art" "reddit.com" "teddit.net" + "tildes.net" "taskiq" "twitter.com" "nitter.net" )) @@ -562,11 +563,6 @@ See also `crux-reopen-as-root-mode'." (setup (:straight expand-region) (:+key "C-=" 'er/expand-region)) -(setup (:straight (filldent - :host github - :repo "duckwork/filldent.el")) - (:+key "M-q" 'filldent-dwim)) - (setup (:straight (frowny :host github :repo "duckwork/frowny.el")) @@ -747,7 +743,6 @@ See also `crux-reopen-as-root-mode'." "C-c C-p" '+org-previous-heading-widen) (:+leader "c" 'org-capture "C-c" 'org-capture "a" 'org-agenda "C-a" 'org-agenda) - (:local-set unfill-fill-function 'org-fill-paragraph) (:local-hook before-save-hook '+org-before-save@prettify-buffer) (advice-add 'org-delete-backward-char :override '+org-delete-backward-char) (with-eval-after-load 'org @@ -868,11 +863,6 @@ See also `crux-reopen-as-root-mode'." undo-fu-session-compression (eq system-type 'gnu/linux)) (global-undo-fu-session-mode +1)) -(setup (:straight (unfill :host github :repo "purcell/unfill" - :fork (:host github :repo "duckwork/unfill"))) - (:bind-into text-mode - "M-q" #'unfill-toggle)) - (setup (:straight (vertico :host github :repo "minad/vertico" diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 3fe243c..ecf1ec5 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -201,20 +201,45 @@ kill without asking." (save-buffers-kill-emacs)) (server-save-buffers-kill-terminal nil))) +(defun +filldent-dwim (&optional arg) + "Fill and indent region if active, or current defun/paragraph. +Optional ARG causes the paragraph to \"unfill.\"" + ;; I wrote a whole package for this --- filldent.el --- but under further + ;; inspection it seems as though Emacs is smart enough in most cases. + ;; Possible TODO: make calling this twice in a row restore the buffer how it + ;; was. + (interactive "*P") + (let ((fill-column (if arg most-positive-fixnum fill-column))) + (if (region-active-p) + (progn + (fill-region (region-beginning) (region-end)) + (indent-region (region-beginning) (region-end))) + (progn + (fill-paragraph) + (save-excursion + (mark-defun) + (indent-region (region-beginning) (region-end))))))) + ;;; Bindings -(global-set-key (kbd "C-x C-c") '+save-buffers-quit) -(global-set-key (kbd "M-SPC") '+cycle-spacing) -(global-set-key (kbd "M-/") 'hippie-expand) -(global-set-key (kbd "M-=") 'count-words) -(global-set-key (kbd "C-x C-b") 'ibuffer) -(global-set-key (kbd "C-s") 'isearch-forward-regexp) -(global-set-key (kbd "C-r") 'isearch-backward-regexp) -(global-set-key (kbd "C-M-s") 'isearch-forward) -(global-set-key (kbd "C-M-r") 'isearch-backward) -(global-set-key (kbd "M-u") 'upcase-dwim) -(global-set-key (kbd "M-l") 'downcase-dwim) -(global-set-key (kbd "M-c") 'capitalize-dwim) +;; I need to place these bindings under `+key-mode-map' so that they aren't +;; shadowed by other maps. There might be a better way to do this. +(require +key) + +(dolist (binding '(("C-x C-c" . +save-buffers-quit) + ("M-SPC" . +cycle-spacing) + ("M-/" . hippie-expand) + ("M-=" . count-words) + ("M-q" . +filldent-dwim) + ("C-x C-b" . ibuffer) + ("C-s" . isearch-forward-regexp) + ("C-r" . isearch-backward-regexp) + ("C-M-s" . isearch-forward) + ("C-M-r" . isearch-backward) + ("M-u" . upcase-dwim) + ("M-l" . downcase-dwim) + ("M-c" . capitalize-dwim))) + (define-key +key-mode-map (kbd (car binding)) (cdr binding))) ;;; Required libraries -- cgit 1.4.1-21-gabe81