aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2025-03-06 12:41:57 +0100
committerStefan Kangas2025-03-07 09:04:52 +0100
commit53b84f7fddbcde969f44318ffcdab889c767352c (patch)
tree8bdacad9f76789122014832d09eda6e18f715b1d
parent2dea3a0d34859852d3577f6054acb49f6e515eb2 (diff)
downloademacs-53b84f7fddbcde969f44318ffcdab889c767352c.tar.gz
emacs-53b84f7fddbcde969f44318ffcdab889c767352c.zip
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.
-rw-r--r--lisp/gnus/gnus-score.el43
1 files changed, 20 insertions, 23 deletions
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 4f6c12a81ba..a4102ef0b51 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -789,31 +789,28 @@ current score file."
789 (delete-windows-on (current-buffer)) 789 (delete-windows-on (current-buffer))
790 (erase-buffer) 790 (erase-buffer)
791 (insert string ":\n\n") 791 (insert string ":\n\n")
792 (let ((max -1) 792 (let* ((longest-string (+ 4 ; %c, `:', SPACE, a SPACE at end
793 (list alist) 793 (seq-reduce #'max
794 (i 0) 794 (mapcar (lambda (elem)
795 n width pad format) 795 (length (nth idx elem)))
796 ;; find the longest string to display 796 alist)
797 (while list 797 0)))
798 (setq n (length (nth idx (car list)))) 798 (w (1- (window-width)))
799 (unless (> max n) 799 (items-per-line (/ w longest-string))
800 (setq max n)) 800 (item-width (/ w items-per-line))
801 (setq list (cdr list))) 801 (pad (- item-width 3))
802 (setq max (+ max 4)) ; %c, `:', SPACE, a SPACE at end 802 (i 0))
803 (setq n (/ (1- (window-width)) max)) ; items per line 803 ;; Insert `items-per-line' items, each in a field of width
804 (setq width (/ (1- (window-width)) n)) ; width of each item 804 ;; `item-width'.
805 ;; insert `n' items, each in a field of width `width' 805 (dolist (elem alist)
806 (while alist 806 (when (>= i items-per-line)
807 (if (< i n) 807 (setq i 0)
808 ()
809 (setq i 0)
810 (delete-char -1) ; the `\n' takes a char 808 (delete-char -1) ; the `\n' takes a char
811 (insert "\n")) 809 (insert "\n"))
812 (setq pad (- width 3)) 810 (insert (substitute-command-keys
813 (setq format (concat "%c: %-" (int-to-string pad) "s")) 811 (format (concat "\\`%c': %-" (int-to-string pad) "s")
814 (insert (format format (caar alist) (nth idx (car alist)))) 812 (car elem) (nth idx elem))))
815 (setq alist (cdr alist)) 813 (incf i)))
816 (setq i (1+ i))))
817 (goto-char (point-min)) 814 (goto-char (point-min))
818 ;; display ourselves in a small window at the bottom 815 ;; display ourselves in a small window at the bottom
819 (appt-select-lowest-window) 816 (appt-select-lowest-window)