Created
November 6, 2013 00:23
-
-
Save vincentbernat/7328781 to your computer and use it in GitHub Desktop.
Tentative to reattach timestamps from ZNC correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ZNC will replay a buffer and prefix each message with a | |
;; timestamp. Let's extract this timestamp and redefine current-time | |
;; to make them appear as regular timestamp. We use an advice to be | |
;; able to locally define `current-time` function. | |
(defadvice erc-add-timestamp (around vbe/erc-add-timestamp) | |
"Extract timestamp beginning a message and display it like a regular timestamp" | |
(save-match-data | |
(goto-char (point-min)) | |
(if (looking-at "^\\s-*\\S-+ \\[\\([0-9][0-9]\\):\\([0-9][0-9]\\):\\([0-9][0-9]\\)\\] ") | |
(let ((hours (match-string 1)) | |
(minutes (match-string 2)) | |
(seconds (match-string 3)) | |
(start (- (match-beginning 1) 1)) | |
(end (+ (match-end 3) 2))) | |
(delete-region start end) | |
(cl-flet ((current-time () | |
(list 0 | |
(+ (* (string-to-number hours) 3600) | |
(* (string-to-number minutes) 60) | |
(string-to-number seconds)) | |
0 | |
0))) | |
ad-do-it)) | |
ad-do-it))) | |
(ad-activate 'erc-add-timestamp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment