Re-install (new and improved!) filldent.el

This commit is contained in:
Case Duckworth 2021-12-28 22:15:43 -06:00
parent 0411f2a6e5
commit cdb6c1cf89
2 changed files with 5 additions and 20 deletions

View File

@ -656,6 +656,11 @@ 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"))

View File

@ -201,25 +201,6 @@ 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
;; I need to place these bindings under `+key-mode-map' so that they aren't
@ -230,7 +211,6 @@ Optional ARG causes the paragraph to \"unfill.\""
("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)