Function: pulsar--create-pulse

pulsar--create-pulse is a natively compiled function defined in pulsar.el.

Signature

(pulsar--create-pulse LOCUS FACE)

Documentation

Create a pulse spanning the LOCUS using FACE.

LOCUS is a cons cell with two buffer positions.

Source Code

;; Defined in /nix/store/3sr3j7hp5p1wsd8fv5763k239hzdxi1c-emacs-packages-deps/share/emacs/site-lisp/elpa/pulsar-1.4.1/pulsar.el
;; NOTE 2026-02-25: The `cl-letf' in `pulsar--create-pulse' is to make
;; Pulsar work in frames that normally do not produce a pulse, per `pulse-available-p'.
;;
;; The complete thread is here: <https://github.com/protesilaos/pulsar/issues/33>.
;;
;; Below is what I wrote with regard to the choice of `pulsar-tty-color':
;;
;;
;;     For completeness, my rationale with the choice of colour is this:
;;
;;     - We are in an environment which does not guarantee accurate colour reproduction.
;;     - It is almost a given that the frame supports at least 8 colours.
;;     - Of those 8 colours we have black, red, green, yellow, blue, magenta, cyan, white.
;;     - Excluding black and white, the colour that contrasts best against both black and white is red.
;;     - Picking red means we do not need to know the background-mode of the frame, which saves us the extra computations.
;;
;;     The contrast table for the six colours, using Org, where Λ is an alias for modus-themes-contrast:
;;
;;     |         | #000000 | #ffffff |
;;     |---------+---------+---------|
;;     | #ff0000 |    5.25 |    4.00 |
;;     | #00ff00 |   15.30 |    1.37 |
;;     | #0000ff |    2.44 |    8.59 |
;;     | #ffff00 |   19.56 |    1.07 |
;;     | #ff00ff |    6.70 |    3.14 |
;;     | #00ffff |   16.75 |    1.25 |
;;     #+TBLFM: $2='(Λ $1 @1$2);%.2f :: $3='(Λ $1 @1$3);%.2f
(defun pulsar--create-pulse (locus face)
  "Create a pulse spanning the LOCUS using FACE.
LOCUS is a cons cell with two buffer positions."
  (let ((common-fn (lambda (locus face)
                     (let ((pulse-flag t)
                           (pulse-delay pulsar-delay)
                           (pulse-iterations pulsar-iterations)
                           (overlay (make-overlay (car locus) (cdr locus))))
                       (overlay-put overlay 'pulse-delete t)
                       (overlay-put overlay 'window (frame-selected-window))
                       (pulse-momentary-highlight-overlay overlay face)))))
    (if (display-graphic-p)
        (funcall common-fn locus face)
      (cl-letf (((symbol-function 'face-background) (lambda (&rest _) pulsar-tty-color)))
        (funcall common-fn locus face)))))