From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: Background mode
Date: Mon, 27 Jun 2005 03:03:48 +0300 [thread overview]
Message-ID: <87u0jkyekf.fsf@jurta.org> (raw)
In-Reply-To: <87hdfr4t99.fsf_-_@jurta.org> (Juri Linkov's message of "Tue, 21 Jun 2005 19:28:02 +0300")
>>> I see there is a bug not caused by my patch:
>>>
>>> emacs -q -nw -rv
>>>
>>> sets the background mode to light on xterm. But since -rv switches
>>> foreground and background, it should switch the background mode too
>>> from light to dark on xterm.
>>
>> I think this is a bug.
>
> There are also other ways to reproduce this bug, for example, running
> Emacs without -rv option on xterm and evaluating (invert-face 'default).
> Every time it evaluated, it switches the background mode to a
> reversed value: with real black background it sets the light
> background mode; with white background - to dark mode. That's because
> xterm presence is checked only once in startup.el (with setting the
> mode to light), but any subsequent call of `frame-set-background-mode'
> ignores the fact that Emacs runs on xterm. On rxvt (invert-face 'default)
> doesn't change the background mode at all because rxvt.el sets the
> value of `frame-background-mode' permanently.
Below is the patch that fixes this problem. It adds a new internal
variable for the default background mode for terminals.
Index: lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.324
diff -u -r1.324 faces.el
--- lisp/faces.el 23 Jun 2005 21:24:58 -0000 1.324
+++ lisp/faces.el 27 Jun 2005 00:00:55 -0000
@@ -1572,6 +1572,12 @@
(choice-item light)
(choice-item :tag "default" nil)))
+(defvar default-frame-background-mode nil
+ "Internal variable for the default brightness of the background.
+The default `nil' means `dark'. If Emacs runs in non-windowed mode
+from `xterm' or a similar terminal emulator, the value is `light'.
+On rxvt terminal, the value depends on the environment variable
+COLORFGBG.")
(defun frame-set-background-mode (frame)
"Set up display-dependent faces on FRAME.
@@ -1587,13 +1593,13 @@
(intern (downcase bg-resource)))
((and (null window-system) (null bg-color))
;; No way to determine this automatically (?).
- 'dark)
+ (or default-frame-background-mode 'dark))
;; Unspecified frame background color can only happen
;; on tty's.
((member bg-color '(unspecified "unspecified-bg"))
- 'dark)
+ (or default-frame-background-mode 'dark))
((equal bg-color "unspecified-fg") ; inverted colors
- 'light)
+ (if (eq default-frame-background-mode 'light) 'dark 'light))
((>= (apply '+ (x-color-values bg-color frame))
;; Just looking at the screen, colors whose
;; values add up to .6 of the white total
Index: lisp/startup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/startup.el,v
retrieving revision 1.359
diff -u -r1.359 startup.el
--- lisp/startup.el 17 Jun 2005 15:34:39 -0000 1.359
+++ lisp/startup.el 27 Jun 2005 00:00:22 -0000
@@ -444,24 +444,25 @@
;; frame-notice-user-settings didn't (such as on a tty).
;; frame-set-background-mode is idempotent, so it won't
;; cause any harm if it's already been done.
- (let ((frame-background-mode frame-background-mode)
- (frame (selected-frame))
+ (let ((frame (selected-frame))
term)
(when (and (null window-system)
;; Don't override a possibly customized value.
(null frame-background-mode)
- ;; Don't override user specifications.
- (null (frame-parameter frame 'reverse))
+ ;; Don't override a default set by terminal.
+ (null default-frame-background-mode)
(let ((bg (frame-parameter frame 'background-color)))
(or (null bg)
- (member bg '(unspecified "unspecified-bg")))))
+ (member bg '(unspecified "unspecified-bg"
+ "unspecified-fg")))))
+
(setq term (getenv "TERM"))
;; Some files in lisp/term do a better job with the
;; background mode, but we leave this here anyway, in
;; case they remove those files.
(if (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
term)
- (setq frame-background-mode 'light)))
+ (setq default-frame-background-mode 'light)))
(frame-set-background-mode (selected-frame)))))
;; Now we know the user's default font, so add it to the menu.
Index: lisp/term/xterm.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/xterm.el,v
retrieving revision 1.16
diff -u -r1.16 xterm.el
--- lisp/term/xterm.el 12 May 2005 01:35:20 -0000 1.16
+++ lisp/term/xterm.el 27 Jun 2005 00:00:33 -0000
@@ -366,7 +366,7 @@
"Set background mode as appropriate for the default rxvt colors."
(let ((fgbg (getenv "COLORFGBG"))
bg rgb)
- (setq frame-background-mode 'light) ; default
+ (setq default-frame-background-mode 'light)
(when (and fgbg
(string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg))
(setq bg (string-to-number (substring fgbg (match-beginning 1))))
@@ -379,7 +379,7 @@
;; The following line assumes that white is the 15th
;; color in xterm-standard-colors.
(* (apply '+ (car (cddr (nth 15 xterm-standard-colors)))) 0.6))
- (setq frame-background-mode 'dark)))
+ (setq default-frame-background-mode 'dark)))
(frame-set-background-mode (selected-frame))))
;; Do it!
Index: lisp/term/rxvt.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/term/rxvt.el,v
retrieving revision 1.4
diff -u -r1.4 rxvt.el
--- lisp/term/rxvt.el 1 Sep 2003 15:45:36 -0000 1.4
+++ lisp/term/rxvt.el 27 Jun 2005 00:00:33 -0000
@@ -150,7 +150,7 @@
"Set background mode as appropriate for the default rxvt colors."
(let ((fgbg (getenv "COLORFGBG"))
bg rgb)
- (setq frame-background-mode 'light) ; default
+ (setq default-frame-background-mode 'light)
(when (and fgbg
(string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg))
(setq bg (string-to-number (substring fgbg (match-beginning 1))))
@@ -163,7 +163,7 @@
;; The following line assumes that white is the 15th
;; color in rxvt-standard-colors.
(* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6))
- (setq frame-background-mode 'dark)))
+ (setq default-frame-background-mode 'dark)))
(frame-set-background-mode (selected-frame))))
;; Do it!
--
Juri Linkov
http://www.jurta.org/emacs/
next prev parent reply other threads:[~2005-06-27 0:03 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-17 11:47 Diff mode faces Juri Linkov
2005-06-17 13:11 ` Jason Rumney
2005-06-17 14:28 ` Stefan Monnier
2005-06-18 13:54 ` Juri Linkov
2005-06-17 14:34 ` Eli Zaretskii
2005-06-18 13:57 ` Juri Linkov
2005-06-18 15:27 ` Randal L. Schwartz
2005-06-18 16:46 ` Eli Zaretskii
2005-06-19 13:09 ` Juri Linkov
2005-06-19 19:58 ` Eli Zaretskii
2005-06-20 4:48 ` Juri Linkov
2005-06-20 20:18 ` Eli Zaretskii
2005-06-21 16:28 ` Background mode (was: Diff mode faces) Juri Linkov
2005-06-27 0:03 ` Juri Linkov [this message]
2005-06-27 16:46 ` Background mode Richard M. Stallman
2005-06-27 23:52 ` Juri Linkov
2005-06-28 18:47 ` Richard M. Stallman
2005-06-29 3:55 ` Stefan Monnier
2005-06-29 22:21 ` Miles Bader
2005-06-30 17:45 ` Stefan Monnier
2005-07-01 4:03 ` Richard M. Stallman
2005-07-01 15:01 ` Stefan Monnier
2005-06-27 23:55 ` Juri Linkov
2005-06-19 13:05 ` Diff mode faces Juri Linkov
2005-06-19 17:10 ` Luc Teirlinck
2005-06-19 17:34 ` Randal L. Schwartz
2005-06-27 23:55 ` Juri Linkov
2005-06-28 4:57 ` Miles Bader
2005-07-01 23:59 ` Juri Linkov
2005-07-02 3:37 ` Miles Bader
2005-07-05 19:11 ` Richard M. Stallman
2005-07-06 20:53 ` Juri Linkov
2005-07-07 4:05 ` Miles Bader
2005-07-07 6:03 ` Juri Linkov
2005-07-07 4:42 ` Eli Zaretskii
2005-07-09 20:56 ` Juri Linkov
2005-07-10 3:34 ` Eli Zaretskii
2005-07-11 0:06 ` Juri Linkov
2005-07-11 13:43 ` Stefan Monnier
2005-07-11 19:37 ` Eli Zaretskii
2005-07-11 19:46 ` Stefan Monnier
2005-07-12 3:33 ` Eli Zaretskii
2005-07-12 6:51 ` Juri Linkov
2005-07-16 11:17 ` Eli Zaretskii
2005-06-28 13:10 ` Randal L. Schwartz
2005-06-30 21:30 ` Richard M. Stallman
2005-06-30 21:30 ` Richard M. Stallman
2005-07-01 10:13 ` Eli Zaretskii
2005-07-01 23:59 ` Juri Linkov
2005-07-03 18:56 ` xterm colors (was: Diff mode faces) Gaëtan LEURENT
2005-07-04 5:59 ` Eli Zaretskii
2005-07-04 6:17 ` Richard M. Stallman
2005-07-01 23:59 ` Diff mode faces Juri Linkov
2005-06-20 0:25 ` Miles Bader
2005-06-18 2:21 ` Richard Stallman
2005-06-18 13:54 ` Juri Linkov
2005-06-19 3:51 ` Richard Stallman
2005-06-19 14:05 ` Juri Linkov
2005-06-20 3:50 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87u0jkyekf.fsf@jurta.org \
--to=juri@jurta.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).