emacs-devel
[Top][All Lists]
Advanced

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

Re: Little improvements on pulse.el


From: Gabriel
Subject: Re: Little improvements on pulse.el
Date: Thu, 11 Mar 2021 20:42:40 -0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> 3. I could not find any documentation or usage in emacs source code for
>> 'pulse-line-hook-function' and 'pulse-command-advice-flag'. Is the flag
>> 'pulse-command-advice-flag' really needed ? The git history says the
>> last modification of this code was 12+ years ago.
>
> You will find one usage of the hook in CEDET.  In any case, after so
> many years I don't think we should consider removing these without a
> good reason.  Is there such a reason?

The only reason to remove it was because I thought it was not being
used anywhere. If it's used by CEDET, we can keep as it is.

>> 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()






reply via email to

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