Function: erc-modified-channels-display

erc-modified-channels-display is a byte-compiled function defined in erc-track.el.gz.

Signature

(erc-modified-channels-display)

Documentation

Set erc-modified-channels-object(var)/erc-modified-channels-object(fun) according to erc-modified-channels-alist.

Use erc-make-mode-line-buffer-name to create buttons.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-track.el.gz
(defun erc-modified-channels-display ()
  "Set `erc-modified-channels-object' according to `erc-modified-channels-alist'.
Use `erc-make-mode-line-buffer-name' to create buttons."
  (cond ((or (eq 'mostactive erc-track-switch-direction)
	     (eq 'leastactive erc-track-switch-direction))
	 (erc-track-sort-by-activest))
	((eq 'importance erc-track-switch-direction)
	 (erc-track-sort-by-importance)))
  (run-hooks 'erc-track-list-changed-hook)
  (when erc-track-position-in-mode-line
    (let* ((oldobject erc-modified-channels-object)
	   (strings
	    (when erc-modified-channels-alist
	      ;; erc-modified-channels-alist contains all the data we need.  To
	      ;; better understand what is going on, we split things up into
	      ;; four lists: BUFFERS, COUNTS, SHORT-NAMES, and FACES.  These
	      ;; four lists we use to create a new
	      ;; `erc-modified-channels-object' using
	      ;; `erc-make-mode-line-buffer-name'.
	      (let* ((buffers (mapcar #'car erc-modified-channels-alist))
		     (counts (mapcar #'cadr erc-modified-channels-alist))
		     (faces (mapcar #'cddr erc-modified-channels-alist))
                     (long-names (mapcar (lambda (buf)
                                           (or (buffer-name buf)
                                               ""))
					 buffers))
		     (short-names (if (functionp erc-track-shorten-function)
				      (funcall erc-track-shorten-function
					       long-names)
				    long-names))
		     strings)
		(while buffers
		  (when (car short-names)
		    (setq strings (cons (erc-make-mode-line-buffer-name
					 (car short-names)
					 (car buffers)
					 (car faces)
					 (car counts))
					strings)))
		  (setq short-names (cdr short-names)
			buffers (cdr buffers)
			counts (cdr counts)
			faces (cdr faces)))
		strings)))
	   (newobject (erc-modified-channels-object strings)))
      (unless (equal-including-properties oldobject newobject)
	(setq erc-modified-channels-object newobject)
	(force-mode-line-update t)))))