Files
dotemacs/mostalive/convert-chats-to-org.el
T
Willem van den Ende 52dcb8b27c improve layout for readability
split parameters over lines, otherwise it is just one noisy line
2025-10-11 13:30:08 +01:00

31 lines
849 B
EmacsLisp

;;; mostalive/convert-chats-to-org.el -*- lexical-binding: t; -*-
(defun chat-remove-hours-ago ()
"Format chat messages by adding '|' separator and user names."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[0-9]+ hours ago" nil t)
(replace-match ""))))
(ert-deftest test-chat-remove-hours-ago ()
(should (string=
(with-temp-buffer
(insert "17 hours ago")
(goto-char (point-min))
(chat-remove-hours-ago)
(buffer-string))
"")))
(ert-deftest test-replace-hours-ago-regexp-in-string ()
(should (string=
(replace-regexp-in-string "\n\s+[0-9]+ hours ago\s*\n"
"|"
"\n 11 hours ago \n")
"|")))
(ert 'test-replace-hours-ago-regexp-in-string )
;;(ert 'test-chat-remove-hours-ago )