From 296c4d7c09cf66b2a97e8871c5a903fda9d0919e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 28 Oct 2022 19:43:06 -0500 Subject: uhhhhh --- lisp/pita.el | 61 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 28 deletions(-) (limited to 'lisp/pita.el') diff --git a/lisp/pita.el b/lisp/pita.el index 92ebf1b..ed67c92 100644 --- a/lisp/pita.el +++ b/lisp/pita.el @@ -1,6 +1,38 @@ ;;; pita.el --- wrappers making emacs less of a PITA -*- lexical-binding: t -*- ;; 🥙 +;;; utils + +(defun walk-tree-replace (tree find replace) + (let ((r nil)) + (dolist (form tree) + (push (cond ((eq find form) replace) + ((listp form) + (walk-tree-replace form find replace)) + (t form)) + r)) + (reverse r))) + +;;; crux advices +;; these should all go :before the function they're advising. + +(defun with-region-or-buffer (&rest _) + (interactive (if mark-active + (list (region-beginning) (region-end)) + (list (point-min) (point-max))))) + +(defun with-region-or-line (&rest _) + (interactive (if mark-active + (list (region-beginning) (region-end)) + (list (line-beginning-position) (line-end-position))))) + +(defun with-region-or-to-eol (&rest _) + (interactive (if mark-active + (list (region-beginning) (region-end)) + (list (point) (line-end-position))))) + +;;; wrappers + (defmacro with-message (msg &rest body) (declare (indent 1)) (when (listp msg) @@ -16,16 +48,6 @@ (:success (message "%s done" ,m) r) (t (signal (car e) (cdr e))))))) -(defun walk-tree-replace (tree find replace) - (let ((r nil)) - (dolist (form tree) - (push (cond ((eq find form) replace) - ((listp form) - (walk-tree-replace form find replace)) - (t form)) - r)) - (reverse r))) - (defmacro with-pr (msg &rest body) (declare (indent 1)) (when (listp msg) @@ -41,24 +63,7 @@ body) (and ,pr (progress-reporter-done ,pr))))) - -;;; crux advices -;; these should all go :before the function they're advising. - -(defun with-region-or-buffer (&rest _) - (interactive (if mark-active - (list (region-beginning) (region-end)) - (list (point-min) (point-max))))) - -(defun with-region-or-line (&rest _) - (interactive (if mark-active - (list (region-beginning) (region-end)) - (list (line-beginning-position) (line-end-position))))) - -(defun with-region-or-to-eol (&rest _) - (interactive (if mark-active - (list (region-beginning) (region-end)) - (list (point) (line-end-position))))) +;;; wrapper advice (provide 'pita) ;;; pita.el ends here -- cgit 1.4.1-21-gabe81