From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.devel Subject: Re: How to record the line number pixel width for each window. Date: Sat, 07 Dec 2019 18:57:23 -0800 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="81124"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 08 03:58:29 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1idmmC-000KwR-0D for ged-emacs-devel@m.gmane.org; Sun, 08 Dec 2019 03:58:28 +0100 Original-Received: from localhost ([::1]:55030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idmmA-0007X6-SJ for ged-emacs-devel@m.gmane.org; Sat, 07 Dec 2019 21:58:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47906) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1idmlQ-0007UQ-Hj for emacs-devel@gnu.org; Sat, 07 Dec 2019 21:57:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1idmlP-00040w-02 for emacs-devel@gnu.org; Sat, 07 Dec 2019 21:57:39 -0500 Original-Received: from gateway34.websitewelcome.com ([192.185.149.222]:41827) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1idmlO-0003sS-Bm for emacs-devel@gnu.org; Sat, 07 Dec 2019 21:57:38 -0500 Original-Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway34.websitewelcome.com (Postfix) with ESMTP id 3370E14C222 for ; Sat, 7 Dec 2019 20:57:25 -0600 (CST) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id dmlAiB6yrOdBHdmlBiL9nP; Sat, 07 Dec 2019 20:57:25 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=R2gaU9TzwWsOpUqJUeokg57Rvy5uqnf3pWZIrKsJtMQ=; b=JrMttj6HEDx4VRqUeZgn5L4M9y t42jxkSg/9hZFsuvCCW/C7rCbwwP/p69NxlB3vykrAw8aoUKQIcOX5hfp3IlVIB3fj6P4Z33CbMmE T66L3OPooFSEJVCEsH44W+V/V6Zp3kL0U30TEzW8iKG6HX7MHJ8nfyuk6s17WnY1plAo17s7jNtq8 2HQ7j8eFNGBSPXIlGybFpFn92TwCzmK6qJvrZzWlFH9juQF7VM1ol5I/4DIBFh6CXvC61fB51qACh ZUlCqcu1gy5Q8Eb0WlV2CwfA7AqFNDThD5gv8A7XDJP7c+QU5Og+qDlE734pyv4kODaax8IxhsWjo 2p8saDkQ==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:51613 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1idmlA-001WCD-FG; Sat, 07 Dec 2019 20:57:24 -0600 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1idmlA-001WCD-FG X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:51613 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.149.222 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243226 Archived-At: 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. */