Function: embark--select

embark--select is a byte-compiled function defined in embark.el.

Signature

(embark--select &key ORIG-TARGET ORIG-TYPE BOUNDS &allow-other-keys)

Documentation

Add or remove ORIG-TARGET of given ORIG-TYPE to the selection.

If BOUNDS are given, also highlight the target when selecting it.

Source Code

;; Defined in ~/.emacs.d/elpa/embark-20260610.302/embark.el
(cl-defun embark--select
    (&key orig-target orig-type bounds &allow-other-keys)
  "Add or remove ORIG-TARGET of given ORIG-TYPE to the selection.
If BOUNDS are given, also highlight the target when selecting it."
  (cl-flet ((multi-type (x) (car (get-text-property 0 'multi-category x))))
    (if-let* ((existing (seq-find
                         (pcase-lambda (`(,cand . ,ov))
                           (and
                            (equal cand orig-target)
                            (if (and bounds ov)
                                (and (= (car bounds) (overlay-start ov))
                                     (= (cdr bounds) (overlay-end ov)))
                              (let ((cand-type (multi-type cand)))
                                (or (eq cand-type orig-type)
                                    (eq cand-type (multi-type orig-target)))))))
                         embark--selection)))
        (progn
          (when (cdr existing) (delete-overlay (cdr existing)))
          (setq embark--selection (delq existing embark--selection)))
      (let ((target (copy-sequence orig-target)) overlay)
        (when bounds
          (setq overlay (make-overlay (car bounds) (cdr bounds)))
          (overlay-put overlay 'category 'embark-selected-overlay))
        (add-text-properties 0 (length orig-target)
                             `(multi-category ,(cons orig-type orig-target))
                             target)
        (push (cons target overlay) embark--selection))))
  (when embark-selection-indicator
    (add-to-list 'mode-line-misc-info '(:eval (embark--selection-indicator)))
    (force-mode-line-update t)))