aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-07-01 21:49:46 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-07-01 21:49:59 +0200
commit92e1e7b991d06e83aa5bf22911d18019391aa3db (patch)
tree45da60d9c80b077002d040d6c592a4a282ac774a /lisp
parent9b1b08c9b32eaec12c952437a5657e78b84c25cc (diff)
move/rename with-toot-item
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el8
-rw-r--r--lisp/mastodon-toot.el21
2 files changed, 15 insertions, 14 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 41ecd85..2574a0f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -339,14 +339,6 @@ than `pop-to-buffer'."
(message "Looks like there's no item at point?")
,@body))
-(defmacro mastodon-tl--do-if-item-strict (&rest body)
- "Execute BODY if we have a toot object at point.
-Includes boosts, and notifications that display toots."
- (declare (debug t))
- `(if (not (equal 'toot (mastodon-tl--property 'item-type :no-move)))
- (message "Looks like there's no toot at point?")
- ,@body))
-
;;; NAV
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 23de8b7..e934352 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -76,7 +76,6 @@
(autoload 'mastodon-tl--as-string "mastodon-tl")
(autoload 'mastodon-tl--buffer-type-eq "mastodon-tl")
(autoload 'mastodon-tl--clean-tabs-and-nl "mastodon-tl")
-(autoload 'mastodon-tl--do-if-item-strict "mastodon-tl")
(autoload 'mastodon-tl--field "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
(autoload 'mastodon-tl--find-property-range "mastodon-tl")
@@ -267,6 +266,16 @@ send.")
"\\>")) ; boundary end
+;;; MACRO
+
+(defmacro mastodon-tl--with-toot-item (&rest body)
+ "Execute BODY if we have a toot object at point.
+Includes boosts, and notifications that display toots."
+ (declare (debug t))
+ `(if (not (equal 'toot (mastodon-tl--property 'item-type :no-move)))
+ (message "Looks like there's no toot at point?")
+ ,@body))
+
;;; MODE MAP
(defvar mastodon-toot-mode-map
@@ -364,7 +373,7 @@ boosting, or bookmarking toots."
(defun mastodon-toot--toggle-boost-or-favourite (type)
"Toggle boost or favourite of toot at `point'.
TYPE is a symbol, either `favourite' or `boost.'"
- (mastodon-tl--do-if-item-strict
+ (mastodon-tl--with-toot-item
(let ((n-type (mastodon-tl--property 'notification-type :no-move)))
(if (or (equal n-type "follow")
(equal n-type "follow_request"))
@@ -467,7 +476,7 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(defun mastodon-toot--toggle-bookmark ()
"Bookmark or unbookmark toot at point."
(interactive)
- (mastodon-tl--do-if-item-strict
+ (mastodon-tl--with-toot-item
(let ((n-type (mastodon-tl--property 'notification-type :no-move)))
(if (or (equal n-type "follow")
(equal n-type "follow_request"))
@@ -515,7 +524,7 @@ SUBTRACT means we are un-favouriting or unboosting, so we decrement."
(defun mastodon-toot--list-toot-boosters-or-favers (&optional favourite)
"List the favouriters or boosters of toot at point.
With FAVOURITE, list favouriters, else list boosters."
- (mastodon-tl--do-if-item-strict
+ (mastodon-tl--with-toot-item
(let* ((base-toot (mastodon-tl--property 'base-item-id))
(endpoint (if favourite "favourited_by" "reblogged_by"))
(url (mastodon-http--api (format "statuses/%s/%s" base-toot endpoint)))
@@ -948,7 +957,7 @@ instance to edit a toot."
(defun mastodon-toot--edit-toot-at-point ()
"Edit the user's toot at point."
(interactive)
- (mastodon-tl--do-if-item-strict
+ (mastodon-tl--with-toot-item
(let ((toot (or (mastodon-tl--property 'base-toot) ; fave/boost notifs
(mastodon-tl--property 'item-json))))
(if (not (mastodon-toot--own-toot-p toot))
@@ -1174,7 +1183,7 @@ text of the toot being replied to in the compose buffer.
If the region is active, inject it into the reply buffer,
prefixed by >."
(interactive)
- (mastodon-tl--do-if-item-strict
+ (mastodon-tl--with-toot-item
(let* ((quote (when (region-active-p)
(buffer-substring (region-beginning)
(region-end))))