From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Colorful line numbers Date: Fri, 22 Jul 2022 14:42:09 +0300 Message-ID: <837d45l6ge.fsf@gnu.org> References: <87leslpow2.fsf@gmail.com> <83ilnpl8e0.fsf@gnu.org> <874jz9peq0.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21377"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jul 22 13:43:41 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEr4E-0005LJ-UA for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jul 2022 13:43:39 +0200 Original-Received: from localhost ([::1]:58536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEr4D-00008k-88 for ged-emacs-devel@m.gmane-mx.org; Fri, 22 Jul 2022 07:43:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEr2v-0007oo-KP for emacs-devel@gnu.org; Fri, 22 Jul 2022 07:42:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:32864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEr2u-0001Pu-Rv; Fri, 22 Jul 2022 07:42:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=/T6g3MWQk3WS+DvL2F0OvmdjWR6PeD8TdSYFGsHkAgw=; b=m55d35WDhBa+5d6jLS7B xYNiWYPD7HeLCLLO1XzZPNzWJpHZjhsM4fy2FggZm2fRwXzSqbcNWimnxbqo9u28YcE5CbUhZo7IZ H2uHtlY0CEuDnZ3JHi81zvlNdYgzpuwtqJYPoQnQ1FUmnfwXatmRZIMfX9qq+ZkV7zqpaXCIiOiid MOP9uALmttgy9/hkGoPyHXPfIdpZCsN/x3/MV9d9Rt1Gr0r2/rMM9mukmJ+gLaLfUjlZ4p3r78vMZ X2/J7VqqlPrcWxGaUibtmSgwLj58+Du4qMD5+TygB+Mv2gHIyMFfzZXewpGU0tjPyZhXdIrANprM+ U4swIYl8CI8JYg==; Original-Received: from [87.69.77.57] (port=4453 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEr2r-0006Aq-Sv; Fri, 22 Jul 2022 07:42:16 -0400 In-Reply-To: <874jz9peq0.fsf@gmail.com> (message from =?utf-8?B?Sm/Do28g?= =?utf-8?B?VMOhdm9yYQ==?= on Fri, 22 Jul 2022 12:29:59 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:292420 Archived-At: > From: João Távora > Cc: emacs-devel@gnu.org > Date: Fri, 22 Jul 2022 12:29:59 +0100 > > Eli Zaretskii writes: > > >> Could we implement one such mechanism? > > No. The native line-number display is implemented inside the low > > level of the display code, and I don't want to call to Lisp from > > there. If nothing else, it will slow down redisplay when line numbers > > are used, whereas avoiding that slowdown was an explicit goal of > > developing native line-number display. > > Does checking for a given text property on some buffer text call into > Lisp? If it isn't, and it's cheap, then this hypothetical feature could > have very low overhead when not used. You want the line number to have the same face as the character displayed immediately after it? That can be done from C without calling Lisp, but how would that work reliably? Any change in the buffer text will risk breaking the feature. And even this is already a complication I'd like to avoid: line number of a line is rendered before we examine the buffer text of the line (and even know whether there is any text there). Now we would need to look forward in the buffer and get text properties of that text. Which might not work correctly, btw, if jit-lock was not yet invoked to produce the faces there. Likewise if the line is hscrolled, so that the first character displayed to the right of the line number is not the first character of the physical line. > Even if you're opposed the idea, could you perhaps some pointers on how > to implement it, so that I try my hand at it and benchmark the > before/after? The implementation is in maybe_produce_line_number in xdisp.c. > > Why aren't the existing faces enough? > > I would like to propertize each line number's background with a > different color based on assembler information. > > This would create a visually cue similar to the one used in Matt > Godbolt's "Compiler explorer" which works in the browser. There, you > have two side-by-side windows of source code, you enter some C code on > the left and it starts compiling it immediately. If compilation > succeeds, it immediately shows the assembly code on the right. Finally, > it colorizes the lines with a unique and dynamically determined, color > based on the assembler code that each line produces when the file > compiled (according to gcc -g). The reader can visually match these > colors in the left and right windeos to see, to some extent, how the > compiler proceeded. You can change the colors of the text without affecting the line numbers. Line numbers have a distinct face for a good reason. > I've recently discovered Jay Kamat's most excellent rmsbolt.el. It is > is even better than godbolt.org in many aspects but is missing this last > feature, which I would like to add. But instead of highlighting the > whole line, I thought it would be nicer and less distracting if I just > highlighted the line number's background. Why not put some indication on the fringe instead? > > And if they aren't enough, why cannot you use line-number-mode? > > I do use line-number-mode, but I don't understand how it can help me > here. AFAIK it shows me one line number at a time in the modeline, not > besides the text. Sorry, I meant linum-mode.