unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Mode line faces on ttys
@ 2005-08-17 12:55 Romain Francoise
  2005-08-17 14:46 ` Juri Linkov
  0 siblings, 1 reply; 10+ messages in thread
From: Romain Francoise @ 2005-08-17 12:55 UTC (permalink / raw)


Lately I've been seeing some strange behavior of the mode line on ttys,
apparently when you set the foreground of a face to a specific color the
background gets changed but the foreground remains unchanged.

For example, if you start emacs with `emacs -q -nw' then eval this:

   (set-face-foreground 'mode-line "red")

then the background of the mode line will go red, but the foreground
will remain black.  In the past (try in Emacs 21.4), the background
would remain unchanged and only the foreground would change.

I have an old Emacs image from June 10th where it still works, so the
change happened sometime between then and now...

-- 
Romain Francoise <romain@orebokech.com> | I like the streets when
it's a miracle -- http://orebokech.com/ | they're empty, I can make the
                                        | rest up.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 12:55 Mode line faces on ttys Romain Francoise
@ 2005-08-17 14:46 ` Juri Linkov
  2005-08-17 15:25   ` Romain Francoise
                     ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Juri Linkov @ 2005-08-17 14:46 UTC (permalink / raw)
  Cc: emacs-devel

> Lately I've been seeing some strange behavior of the mode line on ttys,
> apparently when you set the foreground of a face to a specific color the
> background gets changed but the foreground remains unchanged.
>
> For example, if you start emacs with `emacs -q -nw' then eval this:
>
>    (set-face-foreground 'mode-line "red")
>
> then the background of the mode line will go red, but the foreground
> will remain black.

This is correct.  Since mode-line has the non-nil :inverse-video
attribute, its foreground and background colors should be inverted.
To see that this behavior is correct, you can try to set both
foreground and background colors in an old Emacs, e.g.:

(set-face-foreground 'mode-line "red")
(set-face-background 'mode-line "green")

and see that the mode line is displayed in inverted colors:
red is applied to the background, and green - to the foreground.

> In the past (try in Emacs 21.4), the background would remain
> unchanged and only the foreground would change.
> I have an old Emacs image from June 10th where it still works, so the
> change happened sometime between then and now...

Old Emacs versions were inconsistent: when both foreground and
background colors were specified, they became inverted.  But when
only one of either foreground or background color was specified
and another color kept its default color value, colors remained
not inverted.

The 2005-06-30 change fixes this inconsistency: if one of either
foreground or background color is not specified, Emacs now uses the
same logic of inversion as in the case if both colors are specified.

This fix also provides the behavior for ttys equivalent to X.
You can try to eval on X (no matter in an old or new Emacs version):

(set-face-inverse-video-p 'mode-line t)
(set-face-foreground 'mode-line "red")

and see that this behavior is exactly the same as on ttys now.

Since this change causes questions, maybe it should be mentioned in 
etc/NEWS?

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 14:46 ` Juri Linkov
@ 2005-08-17 15:25   ` Romain Francoise
  2005-08-17 16:36     ` Juri Linkov
  2005-08-17 16:38   ` Juri Linkov
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Romain Francoise @ 2005-08-17 15:25 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> This is correct.  Since mode-line has the non-nil :inverse-video
> attribute, its foreground and background colors should be inverted.

I see, thanks for the explanation.  It's somewhat confusing that setting
the face foreground actually changes the background on ttys--I
understand the logic, but it's surprising.

How are application writers supposed to handle this if they want the
mode line to "look similar" in X and on ttys?  Use `face-inverse-video-p'
to invert values if needed?

> Since this change causes questions, maybe it should be mentioned in 
> etc/NEWS?

Definitely.

-- 
Romain Francoise <romain@orebokech.com> | I used to think there is no
it's a miracle -- http://orebokech.com/ | future left at all.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 15:25   ` Romain Francoise
@ 2005-08-17 16:36     ` Juri Linkov
  2005-08-18  8:29       ` Romain Francoise
  0 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2005-08-17 16:36 UTC (permalink / raw)
  Cc: emacs-devel

>> This is correct.  Since mode-line has the non-nil :inverse-video
>> attribute, its foreground and background colors should be inverted.
>
> I see, thanks for the explanation.  It's somewhat confusing that setting
> the face foreground actually changes the background on ttys--I
> understand the logic, but it's surprising.

Perhaps the behavior of the :inverse-video face attribute is what is
confusing.  It uses the swapped foreground and background colors for
actual display.

> How are application writers supposed to handle this if they want the
> mode line to "look similar" in X and on ttys?  Use `face-inverse-video-p'
> to invert values if needed?

Application writers can specify the same face attributes on X and on
ttys.  So if :inverse-video was off on X, turn it off on tty too, and
vice versa.

>> Since this change causes questions, maybe it should be mentioned in 
>> etc/NEWS?
>
> Definitely.

In which NEWS section would you expect to find this fix?

Possible candidates:

* Lisp Changes in Emacs 22.1
** Face changes

or

* Incompatible Lisp Changes in Emacs 22.1

or

* Incompatible Editing Changes in Emacs 22.1

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 14:46 ` Juri Linkov
  2005-08-17 15:25   ` Romain Francoise
@ 2005-08-17 16:38   ` Juri Linkov
  2005-08-18 21:15     ` Richard M. Stallman
  2005-08-17 16:43   ` Juri Linkov
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Juri Linkov @ 2005-08-17 16:38 UTC (permalink / raw)


I've looked over the documentation of the functions that work with
the `:inverse-video' attribute in the Emacs Lisp Reference manual, and
I see that the documentation doesn't correspond to actual functions.
The description of `invert-face' is wrong, and `set-face-inverse-video-p'
is missing.  I can install the following patch:

Index: lispref/display.texi
===================================================================
RCS file: /cvsroot/emacs/emacs/lispref/display.texi,v
retrieving revision 1.180
diff -c -r1.180 display.texi
*** lispref/display.texi	11 Aug 2005 19:59:05 -0000	1.180
--- lispref/display.texi	17 Aug 2005 16:21:53 -0000
***************
*** 2288,2297 ****
  Non-@code{nil} means do underline; @code{nil} means don't.
  @end defun
  
  @defun invert-face face &optional frame
! This function inverts the @code{:inverse-video} attribute of face
! @var{face}.  If the attribute is @code{nil}, this function sets it to
! @code{t}, and vice versa.
  @end defun
  
    These functions examine the attributes of a face.  If you don't
--- 2156,2169 ----
  Non-@code{nil} means do underline; @code{nil} means don't.
  @end defun
  
+ @defun set-face-inverse-video-p face inverse-video-p &optional frame
+ This function sets the @code{:inverse-video} attribute of face
+ @var{face}.
+ @end defun
+ 
  @defun invert-face face &optional frame
! This function swaps the foreground and background colors of face
! @var{face}.
  @end defun
  
    These functions examine the attributes of a face.  If you don't
***************
*** 2300,2306 ****
  value for that attribute.
  
  @defun face-foreground face &optional frame inherit
! @defunx face-background face &optional frame
  These functions return the foreground color (or background color,
  respectively) of face @var{face}, as a string.
  
--- 2172,2178 ----
  value for that attribute.
  
  @defun face-foreground face &optional frame inherit
! @defunx face-background face &optional frame inherit
  These functions return the foreground color (or background color,
  respectively) of face @var{face}, as a string.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 14:46 ` Juri Linkov
  2005-08-17 15:25   ` Romain Francoise
  2005-08-17 16:38   ` Juri Linkov
@ 2005-08-17 16:43   ` Juri Linkov
  2005-08-17 18:25   ` Eli Zaretskii
  2005-08-18 14:47   ` Richard M. Stallman
  4 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2005-08-17 16:43 UTC (permalink / raw)


While looking at inverse-related functions , I noticed that there are
two duplicate functions in faces.el: `set-face-underline' and
`set-face-underline-p'.  Since `set-face-underline-p' is documented in
the manual, so I assume that the correct name is `set-face-underline-p'.

The patch below deletes the function `set-face-underline' (with moving
its docstring to the `set-face-underline-p', because the docstring
of `set-face-underline' is more complete), and replaces
`set-face-underline' with an alias to `set-face-underline-p'.

Index: lisp/faces.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/faces.el,v
retrieving revision 1.333
diff -c -r1.333 faces.el
*** lisp/faces.el	6 Aug 2005 22:13:42 -0000	1.333
--- lisp/faces.el	17 Aug 2005 16:29:34 -0000
***************
*** 770,776 ****
    (set-face-attribute face frame :stipple (or stipple 'unspecified)))
  
  
! (defun set-face-underline (face underline &optional frame)
    "Specify whether face FACE is underlined.
  UNDERLINE nil means FACE explicitly doesn't underline.
  UNDERLINE non-nil means FACE explicitly does underlining
--- 770,776 ----
    (set-face-attribute face frame :stipple (or stipple 'unspecified)))
  
  
! (defun set-face-underline-p (face underline-p &optional frame)
    "Specify whether face FACE is underlined.
  UNDERLINE nil means FACE explicitly doesn't underline.
  UNDERLINE non-nil means FACE explicitly does underlining
***************
*** 781,800 ****
    (interactive
     (let ((list (read-face-and-attribute :underline)))
       (list (car list) (eq (car (cdr list)) t))))
-   (set-face-attribute face frame :underline underline))
- 
- 
- (defun set-face-underline-p (face underline-p &optional frame)
-   "Specify whether face FACE is underlined.
- UNDERLINE-P nil means FACE explicitly doesn't underline.
- UNDERLINE-P non-nil means FACE explicitly does underlining.
- FRAME nil or not specified means change face on all frames.
- Use `set-face-attribute' to ``unspecify'' underlining."
-   (interactive
-    (let ((list (read-face-and-attribute :underline)))
-      (list (car list) (eq (car (cdr list)) t))))
    (set-face-attribute face frame :underline underline-p))
  
  
  (defun set-face-inverse-video-p (face inverse-video-p &optional frame)
    "Specify whether face FACE is in inverse video.
--- 781,791 ----
    (interactive
     (let ((list (read-face-and-attribute :underline)))
       (list (car list) (eq (car (cdr list)) t))))
    (set-face-attribute face frame :underline underline-p))
  
+ (define-obsolete-function-alias 'set-face-underline
+                                 'set-face-underline-p "22.1")
+ 
  
  (defun set-face-inverse-video-p (face inverse-video-p &optional frame)
    "Specify whether face FACE is in inverse video.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 14:46 ` Juri Linkov
                     ` (2 preceding siblings ...)
  2005-08-17 16:43   ` Juri Linkov
@ 2005-08-17 18:25   ` Eli Zaretskii
  2005-08-18 14:47   ` Richard M. Stallman
  4 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2005-08-17 18:25 UTC (permalink / raw)
  Cc: romain, emacs-devel

> From: Juri Linkov <juri@jurta.org>
> Date: Wed, 17 Aug 2005 17:46:46 +0300
> Cc: emacs-devel@gnu.org
> 
> Since this change causes questions, maybe it should be mentioned in 
> etc/NEWS?

Hmm... we don't usually document bugfixes in NEWS.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 16:36     ` Juri Linkov
@ 2005-08-18  8:29       ` Romain Francoise
  0 siblings, 0 replies; 10+ messages in thread
From: Romain Francoise @ 2005-08-18  8:29 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> In which NEWS section would you expect to find this fix?

> Possible candidates:

> * Lisp Changes in Emacs 22.1
> ** Face changes

Sounds like the less inappropriate choice...

-- 
Romain Francoise <romain@orebokech.com> | I used to think there is no
it's a miracle -- http://orebokech.com/ | future left at all.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 14:46 ` Juri Linkov
                     ` (3 preceding siblings ...)
  2005-08-17 18:25   ` Eli Zaretskii
@ 2005-08-18 14:47   ` Richard M. Stallman
  4 siblings, 0 replies; 10+ messages in thread
From: Richard M. Stallman @ 2005-08-18 14:47 UTC (permalink / raw)
  Cc: romain, emacs-devel

    Since this change causes questions, maybe it should be mentioned in 
    etc/NEWS?

I think it would be worth a brief mention, but please don't make
it precise and detailed.  That would be too hard to read.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Mode line faces on ttys
  2005-08-17 16:38   ` Juri Linkov
@ 2005-08-18 21:15     ` Richard M. Stallman
  0 siblings, 0 replies; 10+ messages in thread
From: Richard M. Stallman @ 2005-08-18 21:15 UTC (permalink / raw)
  Cc: emacs-devel

    I've looked over the documentation of the functions that work with
    the `:inverse-video' attribute in the Emacs Lisp Reference manual, and
    I see that the documentation doesn't correspond to actual functions.
    The description of `invert-face' is wrong, and `set-face-inverse-video-p'
    is missing.  I can install the following patch:

Please do.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-08-18 21:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-17 12:55 Mode line faces on ttys Romain Francoise
2005-08-17 14:46 ` Juri Linkov
2005-08-17 15:25   ` Romain Francoise
2005-08-17 16:36     ` Juri Linkov
2005-08-18  8:29       ` Romain Francoise
2005-08-17 16:38   ` Juri Linkov
2005-08-18 21:15     ` Richard M. Stallman
2005-08-17 16:43   ` Juri Linkov
2005-08-17 18:25   ` Eli Zaretskii
2005-08-18 14:47   ` Richard M. Stallman

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).