branch: elpa/mastodon
commit 92e1e7b991d06e83aa5bf22911d18019391aa3db
Author: marty hiatt <martianhia...@riseup.net>
Commit: marty hiatt <martianhia...@riseup.net>
    move/rename with-toot-item
---
 lisp/mastodon-tl.el   |  8 --------
 lisp/mastodon-toot.el | 21 +++++++++++++++------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 41ecd8529f..2574a0f908 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 23de8b7373..e934352690 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))))

Reply via email to