New function rxvt-colorfgbg-background-mode

* lisp/term/rxvt.el (rxvt-colorfgbg-background-mode): New
function (bug#80486).
(rxvt-set-background-mode): Call it.

Copyright-paperwork-exempt: yes
This commit is contained in:
Peter Oliver 2026-02-25 12:29:20 +00:00 committed by Sean Whitton
parent 91c8c0cc98
commit 58b195e5a3

View file

@ -200,9 +200,13 @@
;; intelligent way than the default guesswork in startup.el.
(defun rxvt-set-background-mode ()
"Set background mode as appropriate for the default rxvt colors."
(let ((fgbg (getenv "COLORFGBG"))
bg rgb)
(set-terminal-parameter nil 'background-mode 'light)
(set-terminal-parameter nil 'background-mode (rxvt-colorfgbg-background-mode
(getenv "COLORFGBG"))))
(defun rxvt-colorfgbg-background-mode (fgbg)
"Determine background mode.
FGBG is a string of the same meaning as the COLORFGBG environment variable."
(let (bg rgb)
(when (and fgbg
(string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg))
(setq bg (string-to-number (substring fgbg (match-beginning 1))))
@ -215,7 +219,8 @@
;; The following line assumes that white is the 15th
;; color in rxvt-standard-colors.
(* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6))
(set-terminal-parameter nil 'background-mode 'dark)))))
'dark
'light))))
(provide 'term/rxvt)