Function: erc-stamp--defer-date-insertion-on-post-modify

erc-stamp--defer-date-insertion-on-post-modify is a byte-compiled function defined in erc-stamp.el.gz.

Signature

(erc-stamp--defer-date-insertion-on-post-modify HOOK-VAR)

Documentation

Schedule a date stamp to be inserted via HOOK-VAR.

Do so when erc-stamp--deferred-date-stamp and its fn slot are non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-stamp.el.gz
(defun erc-stamp--defer-date-insertion-on-post-modify (hook-var)
  "Schedule a date stamp to be inserted via HOOK-VAR.
Do so when `erc-stamp--deferred-date-stamp' and its `fn' slot are
non-nil."
  (when-let ((data erc-stamp--deferred-date-stamp)
             ((eq (erc-stamp--date-fn data) #'ignore))
             (ct (erc-stamp--date-ts data))
             (rendered (erc-stamp--date-str data))
             (buffer (current-buffer))
             (symbol (make-symbol "erc-stamp--insert-date"))
             (marker (setf (erc-stamp--date-marker data) (point-min-marker))))
    (setf (erc-stamp--date-fn data) symbol)
    (fset symbol
          (lambda (&rest _)
            (remove-hook hook-var symbol)
            (setf (erc-stamp--date-fn data) nil)
            (when (buffer-live-p buffer)
              (with-current-buffer buffer
                (setq erc-stamp--date-stamps
                      (cl-sort (cons data erc-stamp--date-stamps) #'time-less-p
                               :key #'erc-stamp--date-ts))
                (setq erc-stamp--deferred-date-stamp nil)
                (let* ((aligned (erc-stamp--time-as-day ct))
                       (erc-stamp--current-time aligned)
                       (erc--msg-props (map-into '((erc--msg . datestamp)
                                                   (erc--skip track))
                                                 'hash-table))
                       (erc-insert-post-hook
                        `(,(lambda ()
                             (set-marker marker (point-min))
                             (set-marker-insertion-type marker t)
                             (erc--hide-message 'timestamp))
                          ,@erc-insert-post-hook))
                       (erc-insert-timestamp-function
                        #'erc-stamp--propertize-left-date-stamp)
                       (pos (erc-stamp--find-insertion-point marker aligned))
                       ;;
                       erc-timestamp-format erc-away-timestamp-format)
                  (erc--with-spliced-insertion pos
                    (erc-display-message nil nil (current-buffer) rendered))
                  (setf (erc-stamp--date-ts data) aligned))
                (setq erc-timestamp-last-inserted-left rendered)))))
    (add-hook hook-var symbol -90)))