Subject: Re: bug#11430: 24.0.96; Customizing `inverse-video' has no effect on session

From: Stefan Kangas <[email-masked]>
Date: Sun, 23 Jun 2024 11:52:25 -0700

tags 11430 + patch
thanks

Lars Ingebrigtsen <[email-masked]> writes:

> Eli Zaretskii <[email-masked]> writes:
>
>> I'm asking not to remove it yet.  Maybe one of these days I will find
>> time to work on this.  It bugs me (pun intended) that this veteran
>> feature stopped working on TTY frames.
>
> My point is that now -- 20 years after this stopped working -- we should
> step back a bit and look at whether this functionality (which must at
> this remove be seen to be a new feature) makes sense.
>
> And I don't think it does much.  Setting a variable that makes the Emacs
> display go inverse?  That's just kinda odd.

(That was four years ago.)

The attached patch obsoletes 'inverse-video' and makes the variable into
a no-op.
From 2359fdd0f4d36533853704cd023c1dd2115917c2 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Sun, 23 Jun 2024 19:51:23 +0200
Subject: [PATCH] Make 'inverse-video' obsolete

* src/dispnew.c (syms_of_display) <inverse-video>:
* lisp/subr.el (inverse-video): Declare variable as obsolete.
* src/msdos.c (IT_set_face): Don't use above variable.
* lisp/cus-start.el (standard): Remove variable 'inverse-video'
* src/term.c (tty_background_highlight, tty_highlight_if_desired):
Inline calls to 'tty_turn_off_highlight' and delete functions.
Update all callers.  (Bug#11430)
---
 etc/NEWS          |  4 ++++
 lisp/cus-start.el |  1 -
 lisp/subr.el      |  2 ++
 src/dispnew.c     |  3 +--
 src/msdos.c       |  8 --------
 src/term.c        | 52 ++++++++++++-----------------------------------
 6 files changed, 20 insertions(+), 50 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index af32a93d9c4..a034410448a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -30,6 +30,10 @@ applies, and please also update docstrings as needed.
 
 * Changes in Emacs 31.1
 
+** The user option 'inverse-video' is now obsolete.
+It has been broken for a long time, and is now declared obsolete.
+Setting it no longer has an effect.
+
 
 * Editing Changes in Emacs 31.1
 
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index a3299cde564..2c161a18f6a 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -228,7 +228,6 @@ minibuffer-prompt-properties--setter
 					    (repeat (string :format "%v")))
 	     ;; dispnew.c
 	     (baud-rate display integer)
-	     (inverse-video display boolean)
 	     (visible-bell display boolean)
 	     (no-redraw-on-reenter display boolean)
 	     (mouse-prefer-closest-glyph display boolean)
diff --git a/lisp/subr.el b/lisp/subr.el
index ab388630a91..782b2dd5c15 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2043,6 +2043,8 @@ 'native-comp-deferred-compilation
 
 (define-obsolete-function-alias 'fetch-bytecode #'ignore "30.1")
 
+(make-obsolete-variable 'inverse-video nil "31.1")
+
 
 ;;;; Alternate names for functions - these are not being phased out.
 
diff --git a/src/dispnew.c b/src/dispnew.c
index 8bbb818bc19..36c047bba9b 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6827,8 +6827,7 @@ syms_of_display (void)
 and the other strategic decisions made during redisplay.  */);
 
   DEFVAR_BOOL ("inverse-video", inverse_video,
-	       doc: /* Non-nil means invert the entire frame display.
-This means everything is in inverse video which otherwise would not be.  */);
+	       doc: /* This variable is obsolete, and has no effect.  */);
 
   DEFVAR_BOOL ("visible-bell", visible_bell,
 	       doc: /* Non-nil means try to flash the frame to represent a bell.
diff --git a/src/msdos.c b/src/msdos.c
index e9faa48fa70..72c14c2c6d0 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -838,14 +838,6 @@ IT_set_face (int face)
       fg = bg;
       bg = tem;
     }
-  /* If the user requested inverse video, obey.  */
-  if (inverse_video)
-    {
-      unsigned long tem2 = fg;
-
-      fg = bg;
-      bg = tem2;
-    }
   if (tty->termscript)
     fprintf (tty->termscript, "<FACE %d: %lu/%lu[FG:%lu/BG:%lu]>", face,
 	     fp->foreground, fp->background, fg, bg);
diff --git a/src/term.c b/src/term.c
index 1f524880054..11914ef696d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -70,7 +70,6 @@
 static void tty_turn_off_highlight (struct tty_display_info *);
 static void tty_show_cursor (struct tty_display_info *);
 static void tty_hide_cursor (struct tty_display_info *);
-static void tty_background_highlight (struct tty_display_info *tty);
 static void clear_tty_hooks (struct terminal *terminal);
 static void set_tty_hooks (struct terminal *terminal);
 static void dissociate_if_controlling_tty (int fd);
@@ -252,7 +251,7 @@ tty_update_end (struct frame *f)
   if (!XWINDOW (selected_window)->cursor_off_p)
     tty_show_cursor (tty);
   tty_turn_off_insert (tty);
-  tty_background_highlight (tty);
+  tty_turn_off_highlight (tty);
   fflush (tty->output);
 }
 
@@ -370,29 +369,6 @@ tty_show_cursor (struct tty_display_info *tty)
 }

-/* Set standout mode to the state it should be in for
-   empty space inside windows.  What this is,
-   depends on the user option inverse-video.  */
-
-static void
-tty_background_highlight (struct tty_display_info *tty)
-{
-  if (inverse_video)
-    tty_turn_on_highlight (tty);
-  else
-    tty_turn_off_highlight (tty);
-}
-
-/* Set standout mode to the mode specified for the text to be output.  */
-
-static void
-tty_highlight_if_desired (struct tty_display_info *tty)
-{
-  if (inverse_video)
-    tty_turn_on_highlight (tty);
-  else
-    tty_turn_off_highlight (tty);
-}
 
 
 /* Move cursor to row/column position VPOS/HPOS.  HPOS/VPOS are
@@ -412,7 +388,7 @@ tty_cursor_to (struct frame *f, int vpos, int hpos)
       && curX (tty) == hpos)
     return;
   if (!tty->TF_standout_motion)
-    tty_background_highlight (tty);
+    tty_turn_off_highlight (tty);
   if (!tty->TF_insmode_motion)
     tty_turn_off_insert (tty);
   cmgoto (tty, vpos, hpos);
@@ -429,7 +405,7 @@ tty_raw_cursor_to (struct frame *f, int row, int col)
       && curX (tty) == col)
     return;
   if (!tty->TF_standout_motion)
-    tty_background_highlight (tty);
+    tty_turn_off_highlight (tty);
   if (!tty->TF_insmode_motion)
     tty_turn_off_insert (tty);
   cmgoto (tty, row, col);
@@ -447,7 +423,7 @@ tty_clear_to_end (struct frame *f)
 
   if (tty->TS_clr_to_bottom)
     {
-      tty_background_highlight (tty);
+      tty_turn_off_highlight (tty);
       OUTPUT (tty, tty->TS_clr_to_bottom);
     }
   else
@@ -469,7 +445,7 @@ tty_clear_frame (struct frame *f)
 
   if (tty->TS_clr_frame)
     {
-      tty_background_highlight (tty);
+      tty_turn_off_highlight (tty);
       OUTPUT (tty, tty->TS_clr_frame);
       cmat (tty, 0, 0);
     }
@@ -497,7 +473,7 @@ tty_clear_end_of_line (struct frame *f, int first_unused_hpos)
 
   if (curX (tty) >= first_unused_hpos)
     return;
-  tty_background_highlight (tty);
+  tty_turn_off_highlight (tty);
   if (tty->TS_clr_line)
     {
       OUTPUT1 (tty, tty->TS_clr_line);
@@ -793,7 +769,7 @@ tty_write_glyphs (struct frame *f, struct glyph *string, int len)
 	  break;
 
       /* Turn appearance modes of the face of the run on.  */
-      tty_highlight_if_desired (tty);
+      tty_turn_off_highlight (tty);
       turn_on_face (f, face_id);
 
       if (n == stringlen)
@@ -855,7 +831,7 @@ tty_write_glyphs_with_face (register struct frame *f, register struct glyph *str
   coding->mode &= ~CODING_MODE_LAST_BLOCK;
 
   /* Turn appearance modes of the face.  */
-  tty_highlight_if_desired (tty);
+  tty_turn_off_highlight (tty);
   turn_on_face (f, face_id);
 
   coding->mode |= CODING_MODE_LAST_BLOCK;
@@ -927,7 +903,7 @@ tty_insert_glyphs (struct frame *f, struct glyph *start, int len)
 	}
       else
 	{
-	  tty_highlight_if_desired (tty);
+	  tty_turn_off_highlight (tty);
 	  turn_on_face (f, start->face_id);
 	  glyph = start;
 	  ++start;
@@ -1031,7 +1007,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
   if (multi)
     {
       raw_cursor_to (f, vpos, 0);
-      tty_background_highlight (tty);
+      tty_turn_off_highlight (tty);
       buf = tparam (multi, 0, 0, i, 0, 0, 0);
       OUTPUT (tty, buf);
       xfree (buf);
@@ -1039,7 +1015,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
   else if (single)
     {
       raw_cursor_to (f, vpos, 0);
-      tty_background_highlight (tty);
+      tty_turn_off_highlight (tty);
       while (--i >= 0)
         OUTPUT (tty, single);
       if (tty->TF_teleray)
@@ -1052,7 +1028,7 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
         raw_cursor_to (f, tty->specified_window - 1, 0);
       else
         raw_cursor_to (f, vpos, 0);
-      tty_background_highlight (tty);
+      tty_turn_off_highlight (tty);
       while (--i >= 0)
         OUTPUTL (tty, scroll, tty->specified_window - vpos);
       tty_set_scroll_region (f, 0, tty->specified_window);
@@ -1992,9 +1968,7 @@ turn_on_face (struct frame *f, int face_id)
      Do this first because TS_end_standout_mode may be the same
      as TS_exit_attribute_mode, which turns all appearances off. */
   if (MAY_USE_WITH_COLORS_P (tty, NC_REVERSE)
-      && (inverse_video
-	  ? fg == FACE_TTY_DEFAULT_FG_COLOR || bg == FACE_TTY_DEFAULT_BG_COLOR
-	  : fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR))
+      && (fg == FACE_TTY_DEFAULT_BG_COLOR || bg == FACE_TTY_DEFAULT_FG_COLOR))
     tty_toggle_highlight (tty);
 
   if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
-- 
2.39.2