summary refs log tree commit diff stats
path: root/lisp/+emacs.el
diff options
context:
space:
mode:
authorCase Duckworth2021-12-25 01:25:25 -0600
committerCase Duckworth2021-12-25 01:25:25 -0600
commit30cd6555bfa43e792eaac5ae32e39d7cafa5a3e2 (patch)
tree2de90a4b6924eb10e8ee20fd494b89a7cbfa5d8d /lisp/+emacs.el
parentChanges and shit (diff)
downloademacs-30cd6555bfa43e792eaac5ae32e39d7cafa5a3e2.tar.gz
emacs-30cd6555bfa43e792eaac5ae32e39d7cafa5a3e2.zip
Bunch of changes; notably +filldent-dwim
I might add this into filldent.el as `filldent-stupidly', later.
Diffstat (limited to 'lisp/+emacs.el')
-rw-r--r--lisp/+emacs.el49
1 files changed, 37 insertions, 12 deletions
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."
201 (save-buffers-kill-emacs)) 201 (save-buffers-kill-emacs))
202 (server-save-buffers-kill-terminal nil))) 202 (server-save-buffers-kill-terminal nil)))
203 203
204(defun +filldent-dwim (&optional arg)
205 "Fill and indent region if active, or current defun/paragraph.
206Optional ARG causes the paragraph to \"unfill.\""
207 ;; I wrote a whole package for this --- filldent.el --- but under further
208 ;; inspection it seems as though Emacs is smart enough in most cases.
209 ;; Possible TODO: make calling this twice in a row restore the buffer how it
210 ;; was.
211 (interactive "*P")
212 (let ((fill-column (if arg most-positive-fixnum fill-column)))
213 (if (region-active-p)
214 (progn
215 (fill-region (region-beginning) (region-end))
216 (indent-region (region-beginning) (region-end)))
217 (progn
218 (fill-paragraph)
219 (save-excursion
220 (mark-defun)
221 (indent-region (region-beginning) (region-end)))))))
222
204;;; Bindings 223;;; Bindings
205 224
206(global-set-key (kbd "C-x C-c") '+save-buffers-quit) 225;; I need to place these bindings under `+key-mode-map' so that they aren't
207(global-set-key (kbd "M-SPC") '+cycle-spacing) 226;; shadowed by other maps. There might be a better way to do this.
208(global-set-key (kbd "M-/") 'hippie-expand) 227(require +key)
209(global-set-key (kbd "M-=") 'count-words) 228
210(global-set-key (kbd "C-x C-b") 'ibuffer) 229(dolist (binding '(("C-x C-c" . +save-buffers-quit)
211(global-set-key (kbd "C-s") 'isearch-forward-regexp) 230 ("M-SPC" . +cycle-spacing)
212(global-set-key (kbd "C-r") 'isearch-backward-regexp) 231 ("M-/" . hippie-expand)
213(global-set-key (kbd "C-M-s") 'isearch-forward) 232 ("M-=" . count-words)
214(global-set-key (kbd "C-M-r") 'isearch-backward) 233 ("M-q" . +filldent-dwim)
215(global-set-key (kbd "M-u") 'upcase-dwim) 234 ("C-x C-b" . ibuffer)
216(global-set-key (kbd "M-l") 'downcase-dwim) 235 ("C-s" . isearch-forward-regexp)
217(global-set-key (kbd "M-c") 'capitalize-dwim) 236 ("C-r" . isearch-backward-regexp)
237 ("C-M-s" . isearch-forward)
238 ("C-M-r" . isearch-backward)
239 ("M-u" . upcase-dwim)
240 ("M-l" . downcase-dwim)
241 ("M-c" . capitalize-dwim)))
242 (define-key +key-mode-map (kbd (car binding)) (cdr binding)))
218 243
219;;; Required libraries 244;;; Required libraries
220 245