Function: erc-dcc-do-LIST-command

erc-dcc-do-LIST-command is a byte-compiled function defined in erc-dcc.el.gz.

Signature

(erc-dcc-do-LIST-command PROC)

Documentation

This is the handler for the /dcc list command.

It lists the current state of erc-dcc-list in an easy to read manner.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-dcc.el.gz
(defun erc-dcc-do-LIST-command (_proc)
  "This is the handler for the /dcc list command.
It lists the current state of `erc-dcc-list' in an easy to read manner."
  (let ((alist erc-dcc-list)
        size elt)
    (erc-display-message
     nil 'notice 'active
     'dcc-list-head)
    (erc-display-message
     nil 'notice 'active
     'dcc-list-line)
    (while alist
      (setq elt (car alist)
            alist (cdr alist))

      (setq size (or (and (plist-member elt :size)
                          (plist-get elt :size))
                     ""))
      (setq size
            (cond ((null size) "")
                 ((numberp size) (number-to-string size))
                 ((string= size "") "unknown")))
      (erc-display-message
       nil 'notice 'active
       'dcc-list-item
       ?n (erc-dcc-nick elt)
       ?t (plist-get elt :type)
       ?a (if (processp (plist-get elt :peer))
              (process-status (plist-get elt :peer))
            "no")
       ?s (concat size
                  ;; FIXME consider uniquified names, e.g., foo.bin<2>
                  (if (and (eq 'GET (plist-get elt :type))
                           (plist-member elt :file)
                           (buffer-live-p (get-buffer (plist-get elt :file)))
                           (plist-member elt :size))
                      (let ((byte-count (with-current-buffer
                                            (get-buffer (plist-get elt :file))
                                          (+ (buffer-size) 0.0
                                             erc-dcc-byte-count))))
                        (format " (%d%%)"
                                (floor (* 100.0 byte-count)
                                       (plist-get elt :size))))))
       ?f (or (and (plist-member elt :file) (plist-get elt :file)) "")
       ?u (if-let* ((flags (concat (and (plist-get elt :turbo) "t")
                                   (and (plist-get elt :secure) "s")))
                    ((not (string-empty-p flags))))
              (concat " (" flags ")")
            "")))
    (erc-display-message
     nil 'notice 'active
     'dcc-list-end)
    t))