From dbb1e5ef4473c418b164b4c74c44cf8ac95e4eb5 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 25 Nov 2024 19:29:40 +1100 Subject: Fixup of previous commit Check nil on reply-to-user, otherwise composing with no mention will error out. --- lisp/mastodon-toot.el | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index bc34bcd..c1deba7 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1785,27 +1785,28 @@ REPLY-REGION is a string to be injected into the buffer." (mastodon-toot--set-cw reply-cw)))) (defun mastodon-toot--warn-remote-suspension (reply-to-user) - (let* ((domains - (delete-dups - (mapcar - (lambda (user) (caddr (string-split user "@"))) - (string-split reply-to-user " ")))) - (suspended-by - (seq-filter - #'mastodon-tl--remote-suspended-p - domains))) - (cond ((length= domains (length suspended-by)) - (display-warning - 'mastodon - "All domains of user mentions in this reply draft have suspended you" - :warning)) - (suspended-by - (display-warning - 'mastodon - (format - "Some domains of user mentions in this reply draft have suspended you: %s" - (string-join suspended-by " ")) - :warning))))) + (when reply-to-user + (let* ((domains + (delete-dups + (mapcar + (lambda (user) (caddr (string-split user "@"))) + (string-split reply-to-user " ")))) + (suspended-by + (seq-filter + #'mastodon-tl--remote-suspended-p + domains))) + (cond ((length= domains (length suspended-by)) + (display-warning + 'mastodon + "All domains of user mentions in this reply draft have suspended you" + :warning)) + (suspended-by + (display-warning + 'mastodon + (format + "Some domains of user mentions in this reply draft have suspended you: %s" + (string-join suspended-by " ")) + :warning)))))) (defun mastodon-toot--update-status-fields (&rest _args) "Update the status fields in the header based on the current state." @@ -2048,8 +2049,9 @@ EDIT means we are editing an existing toot, not composing a new one." (mastodon-toot--display-docs-and-status-fields reply-text) (mastodon-toot--fill-reply-in-compose)) (mastodon-toot--display-docs-and-status-fields)) - (setq reply-to-user (string-join - (delete-dups (string-split reply-to-user " ")) " ")) + (when reply-to-user + (setq reply-to-user (string-join + (delete-dups (string-split reply-to-user " ")) " "))) ;; `reply-to-user' (alone) is also used by `mastodon-tl--dm-user', so ;; perhaps we should not always call --setup-as-reply, or make its ;; workings conditional on reply-to-id. currently it only checks for -- cgit v1.2.3