emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon 9ffe93009c 38/45: edit attachments description fu


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon 9ffe93009c 38/45: edit attachments description fun
Date: Thu, 1 Feb 2024 10:01:03 -0500 (EST)

branch: elpa/mastodon
commit 9ffe93009cbcf40a4b0aab103c8bcd98bb291ba7
Author: marty hiatt <martianhiatus@riseup.net>
Commit: marty hiatt <martianhiatus@riseup.net>

    edit attachments description fun
---
 lisp/mastodon-toot.el | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index f60f3148de..6febec7544 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -1225,6 +1225,30 @@ File is actually attached to the toot upon posting."
     (mastodon-toot--upload-attached-media
      (car (last mastodon-toot--media-attachments)))))
 
+(defun mastodon-toot--attachment-descriptions ()
+  "Return a list of image descriptions for current attachments."
+  (mapcar (lambda (a)
+            (alist-get :description a))
+          mastodon-toot--media-attachments))
+
+(defun mastodon-toot--attachment-from-desc (desc)
+  "Return an attachment based on its description DESC."
+  (car
+   (cl-member-if (lambda (x)
+                   (rassoc desc x))
+                 mastodon-toot--media-attachments)))
+
+(defun mastodon-toot--edit-media-description ()
+  "Prompt for an attachment, and update its description."
+  (interactive)
+  (let* ((descs (mastodon-toot--attachment-descriptions))
+         (choice (completing-read "Attachment: " descs nil :match))
+         (attachment (mastodon-toot--attachment-from-desc choice))
+         (desc-new (read-string "Description: " choice)))
+    (setf (alist-get :description attachment)
+          desc-new)
+    (mastodon-toot--refresh-attachments-display)))
+
 (defun mastodon-toot--upload-attached-media (attachment)
   "Upload a single ATTACHMENT using `mastodon-http--post-media-attachment'.
 The item's id is added to `mastodon-toot--media-attachment-ids',



reply via email to

[Prev in Thread] Current Thread [Next in Thread]