Function: gnus-score-insert-help
gnus-score-insert-help is a byte-compiled function defined in
gnus-score.el.gz.
Signature
(gnus-score-insert-help STRING ALIST IDX)
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-score.el.gz
(defun gnus-score-insert-help (string alist idx)
(setq gnus-score-help-winconf (current-window-configuration))
(with-current-buffer (gnus-get-buffer-create "*Score Help*")
(buffer-disable-undo)
(delete-windows-on (current-buffer))
(erase-buffer)
(insert string ":\n\n")
(let* ((longest-string (+ 4 ; %c, `:', SPACE, a SPACE at end
(seq-reduce #'max
(mapcar (lambda (elem)
(length (nth idx elem)))
alist)
0)))
(w (1- (window-width)))
(items-per-line (/ w longest-string))
(item-width (/ w items-per-line))
(pad (- item-width 3))
(i 0))
;; Insert `items-per-line' items, each in a field of width
;; `item-width'.
(dolist (elem alist)
(when (>= i items-per-line)
(setq i 0)
(delete-char -1) ; the `\n' takes a char
(insert "\n"))
(insert (substitute-command-keys
(format (concat "\\`%c': %-" (int-to-string pad) "s")
(car elem) (nth idx elem))))
(incf i)))
(goto-char (point-min))
;; display ourselves in a small window at the bottom
(appt-select-lowest-window)
(if (< (/ (window-height) 2) window-min-height)
(switch-to-buffer "*Score Help*")
(split-window)
(pop-to-buffer "*Score Help*"))
(let ((window-min-height 1))
(shrink-window-if-larger-than-buffer))
(select-window (gnus-get-buffer-window gnus-summary-buffer t))))