Function: erc-stamp--dedupe-date-stamps
erc-stamp--dedupe-date-stamps is a byte-compiled function defined in
erc-stamp.el.gz.
Signature
(erc-stamp--dedupe-date-stamps OLD-STAMPS)
Documentation
Update erc-stamp--date-stamps from its counterpart OLD-STAMPS.
Assume the contents of the buffer for OLD-STAMPS have just been inserted
above the current buffer's and that the old buffer still exists so that
markers still point somewhere. For each duplicate, update the existing
marker to match the transplanted timestamp with the same date. Also
copy non-duplicate erc-stamp--date objects from OLD-STAMPS to the
current buffer's, maintaining order.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-stamp.el.gz
(defun erc-stamp--dedupe-date-stamps (old-stamps)
"Update `erc-stamp--date-stamps' from its counterpart OLD-STAMPS.
Assume the contents of the buffer for OLD-STAMPS have just been inserted
above the current buffer's and that the old buffer still exists so that
markers still point somewhere. For each duplicate, update the existing
marker to match the transplanted timestamp with the same date. Also
copy non-duplicate `erc-stamp--date' objects from OLD-STAMPS to the
current buffer's, maintaining order."
(let (need)
(dolist (old old-stamps)
(if-let ((new (cl-find (erc-stamp--date-str old) erc-stamp--date-stamps
:test #'string= :key #'erc-stamp--date-str))
(new-marker (erc-stamp--date-marker new)))
;; The new buffer now has a duplicate stamp, so remove the
;; "newer" one from the buffer.
(progn
(erc--delete-inserted-message-naively new-marker)
(set-marker new-marker (erc-stamp--date-marker old)))
;; The new buffer doesn't have this stamp, so add its data
;; object to the sorted list.
(push old need)
;; Update the old marker position to point to the new buffer.
(set-marker (erc-stamp--date-marker old)
(erc-stamp--date-marker old))))
;; These *should* already be sorted.
(setq erc-stamp--date-stamps
(nconc (nreverse need) erc-stamp--date-stamps))))