Subject: bug#47868: 28.0.50; [native-comp] vertico package doesn't work when loading the corresponding eln file

From: Tassilo Horn <[email-masked]>
Date: Sun, 18 Apr 2021 20:49:13 +0200

Andrea Corallo <[email-masked]> writes:

Hi Andrea,

> I think it would be very helpful to know which one is the Emacs
> function that once gets called misbehaves.

That's a bit hard to pinpoint.  It happens during `completing-read'
where the two vertico functions below are called from a
`post-command-hook' in order to display vertico's two overlays, the
"count overlay" before the minibuffer prompt, and the "candidates
overlay" starting after the input string.  Here's a "screenshot" of how
it is supposed to look like, | representing the usual position of point.

[1/3]   Find file: input|
input-candidate1
input-candidate2
input-candidate3

And here are the functions:

--8<---------------cut here---------------start------------->8---
(defun vertico--display-candidates (lines)
  "Update candidates overlay `vertico--candidates-ov' with LINES."
  (move-overlay vertico--candidates-ov (point-max) (point-max))
  (overlay-put vertico--candidates-ov 'after-string
               (apply #'concat #(" " 0 1 (cursor t)) (and lines "\n") lines))
  (let* ((lh (default-line-height))
         (resize (default-value 'resize-mini-windows))
         (dp (- (max (cdr (window-text-pixel-size))
                     (* lh (1+ (if resize (length lines) vertico-count))))
                (window-pixel-height)))
         (dl (ceiling dp lh)))
    (when (or (> dl 0) (eq resize t)) (window-resize nil dl))))

(defun vertico--display-count ()
  "Update count overlay `vertico--count-ov'."
  (when vertico-count-format
    (move-overlay vertico--count-ov (point-min) (point-min))
    (overlay-put vertico--count-ov 'before-string
                 (format (car vertico-count-format)
                         (format (cdr vertico-count-format)
                                 (cond ((>= vertico--index 0) (1+ vertico--index))
                                       ((vertico--allow-prompt-selection-p) "*")
                                       (t "!"))
                                 vertico--total)))))
--8<---------------cut here---------------end--------------->8---

> PS one should just load the .elc file to obtain the corresponding .eln
> loaded.

Ah, ok.

Bye,
Tassilo