branch: elpa/fedi
commit 252361d2078278b641291c96b07c7d55e4c8dd36
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    add generalized fedi-post--update-status-fields-list
---
 fedi-post.el | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fedi-post.el b/fedi-post.el
index 2e5974392e9..1f55346db7e 100644
--- a/fedi-post.el
+++ b/fedi-post.el
@@ -448,6 +448,26 @@ This is how mastodon does it."
                                    "")
                                  'face 'mastodon-cw-face)))))
 
+(defun fedi-post--update-status-fields-list (&rest items)
+  "Update the status fields in the header based on the current state.
+ITEMS is a list of alists, each containing name, prop, item-var, item-face, 
f-str."
+  ;; e.g.
+  ;; (fedi-post--update-status-fields-list `((name . "community")
+  ;;                                         (prop . post-community)
+  ;;                                         (item-var . 
lem-post-community-name)
+  ;;                                         (item-face . nil)
+  ;;                                         (f-str . "To: %s")))
+  (ignore-errors
+    (let* ((inhibit-read-only t))
+      (cl-loop for item in items
+               do (let-alist item
+                    (let ((region (fedi--find-property-range .prop 
(point-min))))
+                      (add-text-properties (car region) (cdr region)
+                                           (list 'display
+                                                 (if .item-var
+                                                     (format .f-str (eval 
.item-var))
+                                                   ""
+                                                   'face .item-face)))))))))
 
 
 ;;; PROPERTIZE TAGS AND HANDLES

Reply via email to