From 79158bd0fd0c67aab90f8ae52d4f90b4b167be22 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 12 Nov 2022 15:38:21 +0100 Subject: wholly remove parent-toot; use base-toot/-id only the confusion came from the three different types of statuses we often encounter: - toot - boost/fave - notification (of boost/fave/mention) in notifications, we can't just use -tl--toot-id. it will return the notif's id, not the base toot's. so we do still fetch base-toot JSON (formerly 'parent-toot prop), and get base-toot-id from there, else from toot JSON. --- lisp/mastodon-toot.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index e203cda..65649b8 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -816,16 +816,15 @@ Customize `mastodon-toot-display-orig-in-reply-buffer' to display text of the toot being replied to in the compose buffer." (interactive) (let* ((toot (mastodon-tl--property 'toot-json)) - ;; NB: we cannot use mastodon-tl--property for 'parent-toot + ;; NB: we cannot use mastodon-tl--property for 'base-toot ;; because if it doesn't have one, it is fetched from next toot! ;; we also cannot use --field because we need to get a different property first - (parent (get-text-property (point) 'parent-toot)) ; for new notifs handling - (id (mastodon-tl--as-string - (mastodon-tl--field 'id (or parent toot)))) + (base-toot (get-text-property (point) 'base-toot)) ; for new notifs handling + (id (mastodon-tl--as-string (mastodon-tl--field 'id (or base-toot toot)))) (account (mastodon-tl--field 'account toot)) (user (alist-get 'acct account)) - (mentions (mastodon-toot--mentions (or parent toot))) - (boosted (mastodon-tl--field 'reblog (or parent toot))) + (mentions (mastodon-toot--mentions (or base-toot toot))) + (boosted (mastodon-tl--field 'reblog (or base-toot toot))) (booster (when boosted (alist-get 'acct (alist-get 'account toot))))) @@ -853,7 +852,7 @@ text of the toot being replied to in the compose buffer." ;; user in mentions already: mentions))) id - (or parent toot)))) + (or base-toot toot)))) (defun mastodon-toot--toggle-warning () "Toggle `mastodon-toot--content-warning'." -- cgit v1.2.3 From 068ab5a5cd17cb04741598ef631d13da004ca8bc Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 12 Nov 2022 17:38:34 +0100 Subject: allow boost/fave of base toot from notifs --- lisp/mastodon-toot.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 65649b8..0571c3b 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -294,9 +294,13 @@ TYPE is a symbol, either 'favourite or 'boost." (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) + ;; & nothing wrong with faving/boosting own toots from notifs: + ;; this boosts/faves the base toot, not the notif status + ((and (equal "reblog" toot-type) + (not (string= (mastodon-tl--get-endpoint) "notifications"))) (error "You can't %s boosts" action-string)) - ((equal "favourite" toot-type) + ((and (equal "favourite" toot-type) + (not (string= (mastodon-tl--get-endpoint) "notifications"))) (error "Your can't %s favourites" action-string)) (t (mastodon-toot--action -- cgit v1.2.3 From 4cd72d73597ee6a5098bdbfb4b22d302e02e618c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 13 Nov 2022 19:07:35 +0100 Subject: fetch and use max chars per option for polls --- lisp/mastodon-toot.el | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 0571c3b..02dc075 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -967,9 +967,18 @@ which is used to attach it to a toot when posting." collect `(,key . ,o)))) (defun mastodon-toot--fetch-max-poll-options () - "Return the maximum number of poll options from the user's instance. " + "Return the maximum number of poll options." + (mastodon-toot--fetch-poll-field 'max_options)) + +(defun mastodon-toot--fetch-max-poll-option-chars () + "Return the maximum number of characters a poll option may have." + (or (mastodon-toot--fetch-poll-field 'max_characters_per_option) + 50)) ; masto default + +(defun mastodon-toot--fetch-poll-field (field) + "Return FIELD from the poll settings from the user's instance. " (let* ((instance (mastodon-http--get-json (mastodon-http--api "instance")))) - (alist-get 'max_options + (alist-get field (alist-get 'polls (alist-get 'configuration instance) instance)))) @@ -988,19 +997,20 @@ MAX is the maximum number set by their instance." (interactive) ;; re length, API docs show a poll 9 options. (let* ((max-options (mastodon-toot--fetch-max-poll-options)) - (length (mastodon-toot--read-poll-options-count max-options)) + (count (mastodon-toot--read-poll-options-count max-options)) + (length (mastodon-toot--fetch-max-poll-option-chars)) (multiple-p (y-or-n-p "Multiple choice? ")) - (options (mastodon-toot--read-poll-options length)) + (options (mastodon-toot--read-poll-options count length)) (hide-totals (y-or-n-p "Hide votes until poll ends? ")) (expiry (mastodon-toot--get-poll-expiry))) (setq mastodon-toot-poll `(:options ,options :length ,length :multi ,multiple-p :hide ,hide-totals :expiry ,expiry)) (message "poll created!"))) -(defun mastodon-toot--read-poll-options (length) +(defun mastodon-toot--read-poll-options (count length) "Read a list of options for poll of LENGTH options." - (cl-loop for x from 1 to length - collect (read-string (format "Poll option [%s/%s]: " x length)))) + (cl-loop for x from 1 to count + collect (read-string (format "Poll option [%s/%s] [max %s chars]: " x count length)))) (defun mastodon-toot--get-poll-expiry () "Prompt for a poll expiry time." -- cgit v1.2.3 From 2cc11e4dd5b77c97922663ac9e4df4d48e77dcde Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 15 Nov 2022 14:48:12 +0100 Subject: only propertize handles and tags if they are bounded by non-words fixes accidental propertizing of handles in links --- lisp/mastodon-toot.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 02dc075..438e887 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1262,10 +1262,10 @@ Added to `after-change-functions'." ;; stops all text after a handle or mention being propertized: (set-text-properties (cdr header-region) (point-max) nil) ;; TODO: confirm allowed hashtag/handle characters: - (mastodon-toot--propertize-item "#[1-9a-zA-Z_]+" + (mastodon-toot--propertize-item "[\n\t ]\\(?2:#[1-9a-zA-Z_]+\\)[\n\t ]" 'success (cdr header-region)) - (mastodon-toot--propertize-item "@[1-9a-zA-Z._-]+" + (mastodon-toot--propertize-item "[\n\t ]\\(?2:@[1-9a-zA-Z._-]+\\)[\n\t ]" 'mastodon-display-name-face (cdr header-region))))) @@ -1274,8 +1274,8 @@ Added to `after-change-functions'." (save-excursion (goto-char start) (cl-loop while (search-forward-regexp regex nil :noerror) - do (add-text-properties (match-beginning 0) - (match-end 0) + do (add-text-properties (match-beginning 2) + (match-end 2) `(face ,face))))) (defun mastodon-toot-compose-buffer-p () -- cgit v1.2.3