Function: erc-make-mode-line-buffer-name
erc-make-mode-line-buffer-name is a byte-compiled function defined in
erc-track.el.gz.
Signature
(erc-make-mode-line-buffer-name STRING BUFFER &optional FACES COUNT)
Documentation
Return a button that switches to BUFFER when clicked.
STRING is the string in the button. It is possibly suffixed with
the number of unread messages, according to variables
erc-track-showcount and erc-track-showcount-string.
If erc-track-use-faces is true and FACES are provided, format
STRING with them. When the mouse hovers above the button, STRING
is displayed according to erc-track-mouse-face.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-track.el.gz
(defun erc-make-mode-line-buffer-name (string buffer &optional faces count)
"Return a button that switches to BUFFER when clicked.
STRING is the string in the button. It is possibly suffixed with
the number of unread messages, according to variables
`erc-track-showcount' and `erc-track-showcount-string'.
If `erc-track-use-faces' is true and FACES are provided, format
STRING with them. When the mouse hovers above the button, STRING
is displayed according to `erc-track-mouse-face'."
;; We define a new sparse keymap every time, because 1. this data
;; structure is very small, the alternative would require us to
;; defvar a keymap, 2. the user is not interested in customizing it
;; (really?), 3. the defun needs to switch to BUFFER, so we would
;; need to save that value somewhere.
(let ((map (make-sparse-keymap))
(name (if (and count erc-track-showcount)
(concat string
erc-track-showcount-string
(int-to-string count))
(copy-sequence string))))
(define-key map (vector 'mode-line 'mouse-2)
(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer buffer))))
(define-key map (vector 'mode-line 'mouse-3)
(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer-other-window buffer))))
(put-text-property 0 (length name) 'local-map map name)
(put-text-property
0 (length name)
'help-echo (concat "mouse-2: switch to buffer, "
"mouse-3: switch to buffer in other window")
name)
(put-text-property 0 (length name) 'mouse-face erc-track-mouse-face name)
(when (and faces erc-track-use-faces)
(put-text-property 0 (length name) 'face faces name))
name))