diff options
author | mousebot <mousebot@riseup.net> | 2021-10-24 10:01:46 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-10-24 10:01:46 +0200 |
commit | 36f9fe238b778d76809facd3d66120c2166f2c30 (patch) | |
tree | d8ff1355c03fd03b99d65ebf6c037c05b74b1443 /lisp/mastodon-toot.el | |
parent | 5cd25e89696dc3aa5db5b4f36bae317547c69802 (diff) | |
parent | 67e515edbbaa660757ecdcf87bbdfe353eb652f2 (diff) |
Merge branch 'develop' into imgcaching
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 0153c9b..983515e 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -29,9 +29,6 @@ ;;; Code: -(defvar mastodon-instance-url) -(defvar mastodon-media--attachment-height) -(defvar mastodon-toot--enable-completion-for-mentions) (when (require 'emojify nil :noerror) (declare-function emojify-insert-emoji "emojify")) @@ -39,6 +36,7 @@ (require 'cl-lib) (require 'company nil :noerror) +(defvar mastodon-instance-url) (autoload 'mastodon-auth--user-acct "mastodon-auth") (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--post "mastodon-http") @@ -81,6 +79,11 @@ Must be one of \"public\", \"unlisted\", \"private\" (for followers-only), or \" :group 'mastodon-toot :type 'string) +(defcustom mastodon-toot--attachment-height 80 + "Height of the attached images preview in the toot draft buffer." + :group 'mastodon-media + :type 'integer) + (when (require 'company nil :noerror) (defcustom mastodon-toot--enable-completion-for-mentions "followers" "Whether to enable company completion for mentions in toot compose buffer." @@ -320,29 +323,26 @@ Remove MARKER if REMOVE is non-nil, otherwise add it." (setq mastodon-toot--content-warning-from-reply-or-redraft toot-cw)) (mastodon-toot--update-status-fields)))))))))) -(defun mastodon-toot--bookmark-toot () - "Bookmark toot at point synchronously." - (interactive) - (let* ((toot (mastodon-tl--property 'toot-json)) - (id (mastodon-tl--as-string (mastodon-tl--toot-id toot))) - (url (mastodon-http--api (format "statuses/%s/bookmark" id)))) - (if (y-or-n-p (format "Bookmark this toot? ")) - (let ((response (mastodon-http--post url nil nil))) - (mastodon-http--triage response - (lambda () - (message "Toot bookmarked!"))))))) - -(defun mastodon-toot--unbookmark-toot () - "Bookmark toot at point synchronously." +(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))) - (url (mastodon-http--api (format "statuses/%s/unbookmark" id)))) - (if (y-or-n-p (format "Remove this toot from your bookmarks? ")) - (let ((response (mastodon-http--post url nil nil))) - (mastodon-http--triage response - (lambda () - (message "Toot unbookmarked!"))))))) + (bookmarked (cdr (assoc '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." @@ -584,7 +584,7 @@ It adds the items' ids to `mastodon-toot--media-attachment-ids', which is used t (or (let ((counter 0) (image-options (when (or (image-type-available-p 'imagemagick) (image-transforms-p)) - `(:height ,mastodon-media--attachment-height)))) + `(:height ,mastodon-toot--attachment-height)))) (mapcan (lambda (attachment) (let* ((data (cdr (assoc :contents attachment))) (image (apply #'create-image data |