31 lines
849 B
EmacsLisp
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 )
|