summary refs log tree commit diff stats
path: root/lisp/pita.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/pita.el')
-rw-r--r--lisp/pita.el61
1 files changed, 33 insertions, 28 deletions
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 @@
1;;; pita.el --- wrappers making emacs less of a PITA -*- lexical-binding: t -*- 1;;; pita.el --- wrappers making emacs less of a PITA -*- lexical-binding: t -*-
2;; 🥙 2;; 🥙
3 3
4;;; utils
5
6(defun walk-tree-replace (tree find replace)
7 (let ((r nil))
8 (dolist (form tree)
9 (push (cond ((eq find form) replace)
10 ((listp form)
11 (walk-tree-replace form find replace))
12 (t form))
13 r))
14 (reverse r)))
15
16;;; crux advices
17;; these should all go :before the function they're advising.
18
19(defun with-region-or-buffer (&rest _)
20 (interactive (if mark-active
21 (list (region-beginning) (region-end))
22 (list (point-min) (point-max)))))
23
24(defun with-region-or-line (&rest _)
25 (interactive (if mark-active
26 (list (region-beginning) (region-end))
27 (list (line-beginning-position) (line-end-position)))))
28
29(defun with-region-or-to-eol (&rest _)
30 (interactive (if mark-active
31 (list (region-beginning) (region-end))
32 (list (point) (line-end-position)))))
33
34;;; wrappers
35
4(defmacro with-message (msg &rest body) 36(defmacro with-message (msg &rest body)
5 (declare (indent 1)) 37 (declare (indent 1))
6 (when (listp msg) 38 (when (listp msg)
@@ -16,16 +48,6 @@
16 (:success (message "%s done" ,m) r) 48 (:success (message "%s done" ,m) r)
17 (t (signal (car e) (cdr e))))))) 49 (t (signal (car e) (cdr e)))))))
18 50
19(defun walk-tree-replace (tree find replace)
20 (let ((r nil))
21 (dolist (form tree)
22 (push (cond ((eq find form) replace)
23 ((listp form)
24 (walk-tree-replace form find replace))
25 (t form))
26 r))
27 (reverse r)))
28
29(defmacro with-pr (msg &rest body) 51(defmacro with-pr (msg &rest body)
30 (declare (indent 1)) 52 (declare (indent 1))
31 (when (listp msg) 53 (when (listp msg)
@@ -41,24 +63,7 @@
41 body) 63 body)
42 (and ,pr (progress-reporter-done ,pr))))) 64 (and ,pr (progress-reporter-done ,pr)))))
43 65
44 66;;; wrapper advice
45;;; crux advices
46;; these should all go :before the function they're advising.
47
48(defun with-region-or-buffer (&rest _)
49 (interactive (if mark-active
50 (list (region-beginning) (region-end))
51 (list (point-min) (point-max)))))
52
53(defun with-region-or-line (&rest _)
54 (interactive (if mark-active
55 (list (region-beginning) (region-end))
56 (list (line-beginning-position) (line-end-position)))))
57
58(defun with-region-or-to-eol (&rest _)
59 (interactive (if mark-active
60 (list (region-beginning) (region-end))
61 (list (point) (line-end-position)))))
62 67
63(provide 'pita) 68(provide 'pita)
64;;; pita.el ends here 69;;; pita.el ends here