Function: erc-cmd-IGNORE

erc-cmd-IGNORE is a byte-compiled function defined in erc.el.gz.

Signature

(erc-cmd-IGNORE &optional USER TIMESPEC)

Documentation

Drop messages from senders, like nick!user@host, matching regexp USER.

With human-readable TIMESPEC, ignore messages from matched senders for the specified duration, like "20m". Without USER, list the contents of erc-ignore-list.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-cmd-IGNORE (&optional user timespec)
  "Drop messages from senders, like nick!user@host, matching regexp USER.
With human-readable TIMESPEC, ignore messages from matched senders for
the specified duration, like \"20m\".  Without USER, list the contents
of `erc-ignore-list'."
  (if user
      (let ((quoted (regexp-quote user))
            (prompt "Add a timeout? (Blank for no, or a time spec like 2h): ")
            timeout msg)
        (when (and (not (string= user quoted))
                   (y-or-n-p (format "Use regexp-quoted form (%s) instead? "
                                     quoted)))
          (setq user quoted))
        (unless timespec
          (setq timespec
                (read-string prompt nil 'erc--read-time-period-history)))
        (setq timeout (erc--decode-time-period (string-trim timespec))
              msg (if timeout
                      (format "Now ignoring %s for %s" user
                              (erc--format-time-period timeout))
                    (format "Now ignoring %s" user)))
        (erc-with-server-buffer
          (when timeout
            (if-let* ((existing (erc--find-ignore-timer user (current-buffer))))
                (timer-set-time existing (timer-relative-time nil timeout))
              (run-at-time timeout nil #'erc--unignore-user user
                           (current-buffer))))
          (erc-display-message nil 'notice 'active msg)
          (cl-pushnew user erc-ignore-list :test #'equal)))
    (if (null (erc-with-server-buffer erc-ignore-list))
        (erc-display-message nil 'notice 'active "Ignore list is empty")
      (erc-display-message nil 'notice 'active "Ignore list:")
      (erc-with-server-buffer
        (let ((seen (copy-sequence erc-ignore-list)))
          (dolist (timer timer-list)
            (when-let* ((args (erc--get-ignore-timer-args timer))
                        ((eq (current-buffer) (nth 1 args)))
                        (user (car args))
                        (delta (- (timer-until timer (current-time))))
                        (duration (erc--format-time-period delta)))
              (setq seen (delete user seen))
              (erc-display-message nil 'notice 'active 'ignore-list
                                   ?p user ?s duration)))
          (dolist (pattern seen)
            (erc-display-message nil 'notice 'active pattern))))))
  t)