1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Use substitute-command-keys in gnus-score-insert-help

* lisp/gnus/gnus-score.el (gnus-score-insert-help): Use
substitute-command-keys.  Clean up the code a bit.
This commit is contained in:
Stefan Kangas 2025-03-06 12:41:57 +01:00
parent 2dea3a0d34
commit 53b84f7fdd

View file

@ -789,31 +789,28 @@ current score file."
(delete-windows-on (current-buffer)) (delete-windows-on (current-buffer))
(erase-buffer) (erase-buffer)
(insert string ":\n\n") (insert string ":\n\n")
(let ((max -1) (let* ((longest-string (+ 4 ; %c, `:', SPACE, a SPACE at end
(list alist) (seq-reduce #'max
(i 0) (mapcar (lambda (elem)
n width pad format) (length (nth idx elem)))
;; find the longest string to display alist)
(while list 0)))
(setq n (length (nth idx (car list)))) (w (1- (window-width)))
(unless (> max n) (items-per-line (/ w longest-string))
(setq max n)) (item-width (/ w items-per-line))
(setq list (cdr list))) (pad (- item-width 3))
(setq max (+ max 4)) ; %c, `:', SPACE, a SPACE at end (i 0))
(setq n (/ (1- (window-width)) max)) ; items per line ;; Insert `items-per-line' items, each in a field of width
(setq width (/ (1- (window-width)) n)) ; width of each item ;; `item-width'.
;; insert `n' items, each in a field of width `width' (dolist (elem alist)
(while alist (when (>= i items-per-line)
(if (< i n)
()
(setq i 0) (setq i 0)
(delete-char -1) ; the `\n' takes a char (delete-char -1) ; the `\n' takes a char
(insert "\n")) (insert "\n"))
(setq pad (- width 3)) (insert (substitute-command-keys
(setq format (concat "%c: %-" (int-to-string pad) "s")) (format (concat "\\`%c': %-" (int-to-string pad) "s")
(insert (format format (caar alist) (nth idx (car alist)))) (car elem) (nth idx elem))))
(setq alist (cdr alist)) (incf i)))
(setq i (1+ i))))
(goto-char (point-min)) (goto-char (point-min))
;; display ourselves in a small window at the bottom ;; display ourselves in a small window at the bottom
(appt-select-lowest-window) (appt-select-lowest-window)