all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: Emacs Devel <emacs-devel@gnu.org>
Subject: How to record the line number pixel width for each window.
Date: Thu, 05 Dec 2019 10:19:07 -0800	[thread overview]
Message-ID: <m2wobad49w.wl%esq@lawlist.com> (raw)

I am working on feature requests 22873 (multiple fake cursors) and 17684 (crosshairs and visible fill column, both of which able to vertically intersect characters at any screen X coordinate).  The latest patch is:

    VERSION: 022.005 [11/17/2019]

    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22873#176

Features 17684/22873 have been purposefully designed to obviate the need to call start_display; i.e., there is no need to move IT in order to obtain any values used in the implementation of 17684/22873.

I do not want to use the built-in function line_number_display_width, which fires up start_display and moves IT to figure out the line number pixel width (among other values).  Instead, I would like to devise a reliable method whereby the display engine records the value (line number pixel width) for each window (wherever features 17684/22873 are active), such that those values are reliably accessible when Emacs calls update_window (located in dispnew.c).

I have been using the snippet below to record the value of the line number pixel width for each window.  This value, however, is unreliable when dealing with a window containing folded/hidden text, such as an org-mode buffer.  When dealing with folded/hidden text (e.g., org-mode), the recorded value sporadically changes while moving the cursor (e.g. pressing the arrow keys) even though the contents of the window do not change.

How can I perfect the recorded value of the line number pixel width, and also avoid expressly firing up a new instance of start_display and moving IT for the sole purpose of determining the value for each window during update_window (in dispnew.c)?

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


diff --git a/src/xdisp.c b/src/xdisp.c
index 2467b33..dd901da 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22720,6 +22720,28 @@ maybe_produce_line_number (struct it *it)
 	}
     }
 
+
+/* *************************************************************************** */
+/* MULTIPLE-CURSORS */
+
+  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	other threads:[~2019-12-05 18:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 18:19 Keith David Bershatsky [this message]
2019-12-06  8:10 ` How to record the line number pixel width for each window Eli Zaretskii
2019-12-06 17:07   ` Keith David Bershatsky
2019-12-06 18:42     ` Eli Zaretskii
2019-12-06 19:29       ` Keith David Bershatsky
2019-12-07  8:27         ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2019-12-08  2:57 Keith David Bershatsky

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2wobad49w.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.