From e975ada204591fe4fb35ce055c726256ccf3004b Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:39:58 +0200 Subject: emoji funs indentation --- lisp/mastodon-toot.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 022cbec..7ff2b78 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -469,10 +469,10 @@ The list is formatted for `emojify-user-emojis', which see." (mapc (lambda (x) (push `(,(concat ":" - (file-name-base x) - ":") . (("name" . ,(file-name-base x)) - ("image" . ,(concat mastodon-custom-emojis-dir x)) - ("style" . "github"))) + (file-name-base x) ":") + . (("name" . ,(file-name-base x)) + ("image" . ,(concat mastodon-custom-emojis-dir x)) + ("style" . "github"))) mastodon-emojify-user-emojis)) custom-emoji-files) (reverse mastodon-emojify-user-emojis))) @@ -486,7 +486,8 @@ to `emojify-user-emojis', and the emoji data is updated." (unless (file-exists-p (concat (expand-file-name emojify-emojis-dir) "/mastodon-custom-emojis/")) - (when (y-or-n-p "Looks like you haven't downloaded your instance's custom emoji yet. Download now? ") + (when (y-or-n-p "Looks like you haven't downloaded your + instance's custom emoji yet. Download now? ") (mastodon-toot--download-custom-emoji))) (setq emojify-user-emojis (append (mastodon-toot--collect-custom-emoji) -- cgit v1.2.3 From 52adc2210f15d89188a8c3cf2bbf07e3849d916c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 7 Aug 2022 20:40:32 +0200 Subject: optional cd in -set-ce refactor --- lisp/mastodon-toot.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 7ff2b78..e5e6ce1 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -365,7 +365,7 @@ NO-REDRAFT means delete toot only." toot-visibility toot-cw))))))))) -(defun mastodon-toot-set-cw (cw) +(defun mastodon-toot-set-cw (&optional cw) "Set content warning to CW if it is non-nil" (unless (equal cw "") (setq mastodon-toot--content-warning t) -- cgit v1.2.3 From b7800ee9cd3267e7e5b220feeac459ac8741c8dd Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 8 Aug 2022 16:10:13 +0200 Subject: re-allow boost/fave of own toots! --- lisp/mastodon-toot.el | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index e5e6ce1..38179be 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -240,26 +240,27 @@ TYPE is a symbol, either 'favourite or 'boost." (remove (if boost-p (when boosted t) (when faved t))) (toot-type (alist-get 'type (mastodon-tl--property 'toot-json)))) (if byline-region - (cond ((mastodon-toot--own-toot-p (mastodon-tl--property 'toot-json)) - (error "You can't %s your own toots." action-string)) - ((equal "reblog" toot-type) - (error "You can't %s boosts." action-string)) - ((equal "favourite" toot-type) - (error "Your can't %s favourites." action-string)) - (t - (mastodon-toot--action - action - (lambda () - (let ((inhibit-read-only t)) - (add-text-properties (car byline-region) - (cdr byline-region) - (if boost-p - (list 'boosted-p (not boosted)) - (list 'favourited-p (not faved)))) - (mastodon-toot--action-success - (if boost-p "B" "F") - byline-region remove)) - (message (format "%s #%s" (if boost-p msg action) id)))))) + (cond ;; actually there's nothing wrong with faving/boosting own toots! + ;;((mastodon-toot--own-toot-p (mastodon-tl--property 'toot-json)) + ;;(error "You can't %s your own toots." action-string)) + ((equal "reblog" toot-type) + (error "You can't %s boosts." action-string)) + ((equal "favourite" toot-type) + (error "Your can't %s favourites." action-string)) + (t + (mastodon-toot--action + action + (lambda () + (let ((inhibit-read-only t)) + (add-text-properties (car byline-region) + (cdr byline-region) + (if boost-p + (list 'boosted-p (not boosted)) + (list 'favourited-p (not faved)))) + (mastodon-toot--action-success + (if boost-p "B" "F") + byline-region remove)) + (message (format "%s #%s" (if boost-p msg action) id)))))) (message (format "Nothing to %s here?!?" action-string))))) (defun mastodon-toot--toggle-boost () -- cgit v1.2.3 From 88895d0c8307f27c643171cc7095c876856fe300 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 20 Aug 2022 15:42:50 +0200 Subject: FIX bookmark toggle, updating display in byline just boilerplate copying fave/boost funs for now, better than nothing. --- lisp/mastodon-tl.el | 8 +++---- lisp/mastodon-toot.el | 59 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 27 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d5a893d..aab0509 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -533,6 +533,9 @@ By default it is `mastodon-tl--byline-boosted'" (faved (equal 't (mastodon-tl--field 'favourited toot))) (boosted (equal 't (mastodon-tl--field 'reblogged toot))) (bookmarked (equal 't (mastodon-tl--field 'bookmarked toot))) + (bookmark-str (if (fontp (char-displayable-p #10r128278)) + "🔖" + "K")) (visibility (mastodon-tl--field 'visibility toot))) (concat ;; Boosted/favourited markers are not technically part of the byline, so @@ -547,10 +550,7 @@ By default it is `mastodon-tl--byline-boosted'" (when faved (mastodon-tl--format-faved-or-boosted-byline "F")) (when bookmarked - (mastodon-tl--format-faved-or-boosted-byline - (if (fontp (char-displayable-p #10r128278)) - "🔖" - "K")))) + (mastodon-tl--format-faved-or-boosted-byline bookmark-str))) (propertize (concat ;; we propertize help-echo format faves for author name diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 38179be..821dd43 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -216,8 +216,6 @@ Makes a POST request to the server." (let ((response (mastodon-http--post url nil nil))) (mastodon-http--triage response callback)))) - - (defun mastodon-toot--toggle-boost-or-favourite (type) "Toggle boost or favourite of toot at `point'. TYPE is a symbol, either 'favourite or 'boost." @@ -273,6 +271,42 @@ TYPE is a symbol, either 'favourite or 'boost." (interactive) (mastodon-toot--toggle-boost-or-favourite 'favourite)) +;; TODO maybe refactor into boost/fave fun +(defun mastodon-toot--bookmark-toot-toggle () + "Bookmark or unbookmark toot at point." + (interactive) + (let* ((toot (mastodon-tl--property 'toot-json)) + (id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) + (bookmarked-p (mastodon-tl--property 'bookmarked-p)) + (prompt (if bookmarked-p + (format "Toot already bookmarked. Remove? ") + (format "Bookmark this toot? "))) + (byline-region + (when id + (mastodon-tl--find-property-range 'byline (point)))) + (action (if bookmarked-p "unbookmark" "bookmark")) + (bookmark-str (if (fontp (char-displayable-p #10r128278)) + "🔖" + "K")) + (message (if bookmarked-p + "Bookmark removed!" + "Toot bookmarked!")) + (remove (when bookmarked-p t))) + (if byline-region + (when (y-or-n-p prompt) + (mastodon-toot--action + action + (lambda () + (let ((inhibit-read-only t)) + (add-text-properties (car byline-region) + (cdr byline-region) + (list 'bookmarked-p (not bookmarked-p)))) + (mastodon-toot--action-success + bookmark-str + byline-region remove) + (message (format "%s #%s" message id))))) + (message (format "Nothing to %s here?!?" action))))) + (defun mastodon-toot--copy-toot-url () "Copy URL of toot at point." (interactive) @@ -388,27 +422,6 @@ REPLY-ID, TOOT-VISIBILITY, and TOOT-CW of deleted toot are preseved." (mastodon-toot-set-cw toot-cw) (mastodon-toot--update-status-fields)))) -(defun mastodon-toot--bookmark-toot-toggle () - "Bookmark or unbookmark toot at point synchronously." - (interactive) - (let* ((toot (mastodon-tl--property 'toot-json)) - (id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) - (bookmarked (alist-get 'bookmarked toot)) - (url (mastodon-http--api (if (equal bookmarked t) - (format "statuses/%s/unbookmark" id) - (format "statuses/%s/bookmark" id)))) - (prompt (if (equal bookmarked t) - (format "Toot already bookmarked. Remove? ") - (format "Bookmark this toot? "))) - (message (if (equal bookmarked t) - "Bookmark removed!" - "Toot bookmarked!"))) - (when (y-or-n-p prompt) - (let ((response (mastodon-http--post url nil nil))) - (mastodon-http--triage response - (lambda () - (message message))))))) - (defun mastodon-toot--kill () "Kill `mastodon-toot-mode' buffer and window." (kill-buffer-and-window)) -- cgit v1.2.3 From 705adb3ae86ee2c09074e9938673fc9083b9ab9d Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 20 Aug 2022 16:25:52 +0200 Subject: tl--bookmark-toggle: use 'base-toot-id prop --- lisp/mastodon-toot.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 821dd43..3081637 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -276,7 +276,8 @@ TYPE is a symbol, either 'favourite or 'boost." "Bookmark or unbookmark toot at point." (interactive) (let* ((toot (mastodon-tl--property 'toot-json)) - (id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) + (id (mastodon-tl--property 'base-toot-id)) + ;; (mastodon-tl--as-string (mastodon-tl--toot-id toot))) (bookmarked-p (mastodon-tl--property 'bookmarked-p)) (prompt (if bookmarked-p (format "Toot already bookmarked. Remove? ") -- cgit v1.2.3