emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to record the line number pixel width for each window.


From: Keith David Bershatsky
Subject: Re: How to record the line number pixel width for each window.
Date: Sat, 07 Dec 2019 18:57:23 -0800

Thank you, Eli, for your insight -- greatly appreciated!  Based on your helpful 
comments and also based upon examining the code for line_number_display_width, 
I came up with the following conditions to use when setting the window object 
with the line number pixel width (which is set from within 
maybe_produce_line_number):

  if (it->area == TEXT_AREA
      && IT_CHARPOS (*it) == wstart.charpos)
    {
      [Set the window object with the line number pixel width.]
    }

The entire snippet is listed below.  I did some limited testing this evening in 
an org-mode buffer and so far so good.  I will continue to test out the revised 
code in the coming days to see if any problems arise.


diff --git a/src/xdisp.c b/src/xdisp.c
index 2467b33..dfc9a61 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22720,6 +22720,34 @@ maybe_produce_line_number (struct it *it)
        }
     }
 
+
+/* *************************************************************************** 
*/
+/* MULTIPLE-CURSORS */
+
+  struct text_pos wstart;
+  SET_TEXT_POS_FROM_MARKER (wstart, it->w->start);
+  if (it->area == TEXT_AREA
+      && IT_CHARPOS (*it) == wstart.charpos)
+    {
+      struct buffer *b = XBUFFER (it->w->contents);
+      struct buffer *old_buffer = NULL;
+      /* Needed so that buffer-local values can be determined; e.g., when 
switching
+      to the minibuffer. */
+      if (b != current_buffer)
+        {
+          old_buffer = current_buffer;
+          set_buffer_internal (b);
+        }
+      it->w->mc.lnum_pixel_width = (!NILP (Vdisplay_line_numbers))
+                                   ? tem_it.current_x
+                                   : 0;
+      if (old_buffer)
+        set_buffer_internal (old_buffer);
+    }
+
+/* *************************************************************************** 
*/
+
+
   /* Record the width in pixels we need for the line number display.  */
   it->lnum_pixel_width = tem_it.current_x;
   /* Copy the produced glyphs into IT's glyph_row.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]