all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Little improvements on pulse.el
@ 2021-03-10  5:39 Gabriel
  2021-03-10 12:13 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gabriel @ 2021-03-10  5:39 UTC (permalink / raw)
  To: emacs-devel

I have been playing with pulse.el in the last few days and some
ideas/questions come to my mind.

This is the current source code of 'pulse-line-hook-function':

(defun pulse-line-hook-function ()
  "Function used in hooks to pulse the current line.
Only pulses the line if `pulse-command-advice-flag' is non-nil."
  (when pulse-command-advice-flag
    (pulse-momentary-highlight-one-line (point))))

1. It can be useful in some cases to pulse the current line by using an
interactive command, for example, when doing a presentation, a pairing
with other developer, or to easily find the cursor position. Since
'pulse-line-hook-function' is not a good name for an interactive
function, we can create a new command for that.

2. The name and the docstring mention the use with hooks, but would be
nice to use with advices as well. For example, to highlight the current
line when the cursor, buffer or window changes:

(dolist (symbol '(scroll-up-command
                  scroll-down-command
                  recenter-top-bottom
                  other-window
                  windmove-do-window-select
                  kill-current-buffer
                  delete-window))
  (advice-add symbol :after #'pulse-line-hook-function))

The code above does not work, since 'pulse-line-hook-function' does not
accept any argument (sent by the advice function). We can make it accept
optional arguments, but again the name will not be the best one.

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.

4. Would be nice to have support for 'pulse-highlight-start-face' in the
themes provided by Emacs, especially on modus-themes.

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:

(let* ((start (color-name-to-rgb (face-background 'pulse-highlight-start-face)))
       (end (color-name-to-rgb (face-background 'default)))
       (gradient-rgb (append (list start)
                             (color-gradient start end pulse-iterations)
                             (list end)))
       (gradient-hex (mapcar (apply-partially 'apply 'color-rgb-to-hex) gradient-rgb)))
  (seq-do-indexed (lambda (color index)
                    (run-with-timer (* index pulse-delay)
                                    nil
                                    (apply-partially 'funcall
                                                     (lambda (color)
                                                       (set-face-background 'default
                                                                            color))
                                                     color)))
                  gradient-hex))

Please share your comments and suggestions. I have FSF copyright
assignment and can open patches for these (or other) improvements/bugs.

Regards,
Gabriel



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-12  7:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-10  5:39 Little improvements on pulse.el Gabriel
2021-03-10 12:13 ` Eli Zaretskii
2021-03-10 13:41   ` Stefan Kangas
2021-03-10 17:18     ` Juri Linkov
2021-03-10 18:51       ` Juri Linkov
2021-03-10 19:11         ` Eli Zaretskii
2021-03-11 23:42   ` Gabriel
2021-03-12  7:29     ` Eli Zaretskii
2021-03-10 18:59 ` Juri Linkov
2021-03-11 15:35 ` Stefan Monnier

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.