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: Little improvements on pulse.el Date: Fri, 12 Mar 2021 09:29:36 +0200 Message-ID: <83sg50lti7.fsf@gnu.org> References: <83ft13p5ow.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18495"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Gabriel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Mar 12 08:30:11 2021 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 1lKcFP-0004in-Gp for ged-emacs-devel@m.gmane-mx.org; Fri, 12 Mar 2021 08:30:11 +0100 Original-Received: from localhost ([::1]:45388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKcFO-00086W-JE for ged-emacs-devel@m.gmane-mx.org; Fri, 12 Mar 2021 02:30:10 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKcEr-0007cv-Tz for emacs-devel@gnu.org; Fri, 12 Mar 2021 02:29:37 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55036) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKcEr-0000uP-66; Fri, 12 Mar 2021 02:29:37 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4262 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lKcEo-0000TU-QU; Fri, 12 Mar 2021 02:29:36 -0500 In-Reply-To: (message from Gabriel on Thu, 11 Mar 2021 20:42:40 -0300) 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:266384 Archived-At: > From: Gabriel > Date: Thu, 11 Mar 2021 20:42:40 -0300 > > >> 5. The code on 'pulse-lighten-highlight' can be significantly improved > >> by replacing 'pulse-int-to-hex' and 'pulse-color-values-to-hex' with > >> 'color-gradient' from color.el. The idea is to build the list of color > >> gradients beforehand and use a timer to set each color according to > >> 'pulse-iterations' and 'pulse-delay'. A very basic example: > > > > I'm not sure I understand the improvement, can you elaborate? > > I will try to briefly explain how it works and how it could be > improved. The main function ('pulse-momentary-highlight-overlay') runs > 'pulse-tick' with a timer, passing a stop-time as parameter. The > 'pulse-tick' calls 'pulse-lighten-highlight' that has a complex logic to > calculate the next color for the pulse overlay. It basically checks for > the current iteration number and calculates the appropriate RGB (a > little bit lighter than the previous one), using a helper function in > the same file ('pulse-color-values-to-hex'). All this code can be > replaced by 'color-gradient' from 'color.el' that, according to Stefan > Monnier in another thread, was added to Emacs after pulse.el. The > pseudo-code is: > > for each color in color-gradients(start, stop, length): > update-overlay(color) > sleep() OK, so the timer thing is still needed, right? color-gradients only replace the calculation of the next color. SGTM, thanks.