From d7e3ae509c77a1a168e4a811755444ae89f57466 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 2 May 2023 11:49:32 +0200 Subject: refactor format reply in compose str, propertize docs properly. FIX #448. --- lisp/mastodon-toot.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 474337b..e77ddf3 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1415,6 +1415,19 @@ LONGEST is the length of the longest binding." longest-kbind) nil)))) +(defun mastodon-toot--format-reply-in-compose-string (reply-text) + "Format a REPLY-TEXT for display in compose buffer docs." + (let* ((rendered (mastodon-tl--render-text reply-text)) + (no-newlines (replace-regexp-in-string "\n\n" "\n" rendered))) + (concat " Reply to:\n\"" + ;; (propertize + (truncate-string-to-width + no-newlines + mastodon-toot-orig-in-reply-length) + ;; overridden by containing propertize call: + ;; 'face 'mastodon-toot-docs-reply-text-face) + "...\"\n"))) + (defun mastodon-toot--display-docs-and-status-fields (&optional reply-text) "Insert propertized text with documentation about `mastodon-toot-mode'. Also includes and the status fields which will get updated based @@ -1449,22 +1462,12 @@ REPLY-TEXT is the text of the toot being replied to." " Attachments: " (propertize "None " 'toot-attachments t) + "\n" + (if reply-text + (mastodon-toot--format-reply-in-compose-string reply-text) + "") + divider "\n") - 'face font-lock-comment-face - 'read-only "Edit your message below." - 'toot-post-header t) - (if reply-text - (concat - (propertize (truncate-string-to-width - (mastodon-tl--render-text reply-text) - mastodon-toot-orig-in-reply-length) - 'read-only "Edit your message below." - 'toot-post-header t - 'face '(variable-pitch :foreground "#7c6f64")) - "\n") - "") - (propertize - (concat divider "\n") 'rear-nonsticky t 'face font-lock-comment-face 'read-only "Edit your message below." -- cgit v1.2.3