Subject: 27.1; Adaptive-Wrap causes font-locking errors when combined with consult.el

From: Shane Segal <[email-masked]>
Date: Wed, 16 Dec 2020 13:44:34 -0500

Hi, I'm using the adaptive-wrap package in combination with consult[0]
and selectrum[0]. When adaptive-wrap-prefix-mode is enabled, searching
through lines in an org or latex file with consult-line (similar to
swiper from the ivy package) fails to launch, with the following error
message:

    Error during redisplay: (jit-lock-function 228) signaled (error
"Invalid face" font-lock-comment-face org-block)
    face-attribute: Invalid face: font-lock-comment-face, org-
blockError during redisplay: (jit-lock-function 228) signaled (error
"Invalid face" font-lock-comment-face org-block)

This doesn't appear to be a bug with the consult package, as there
isn't
anything special going on with the font-locking code in consult. See
the github
issue here[2]. Note that I'm not the consult developer, simply sending
this bug report on their behalf.

I have a sample init file that can reproduce the error if loaded.

This will download the appropriate packages (from github, so if you
have
moral issues with that, feel free to ignore?):

    (defvar bootstrap-version)
    (let ((bootstrap-file
        (expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
        (bootstrap-version 5))
    (unless (file-exists-p bootstrap-file)

        (with-current-buffer
            (url-retrieve-synchronously
           
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el
"
            'silent 'inhibit-cookies)
        (goto-char (point-max))
        (eval-print-last-sexp)))
    (load bootstrap-file nil 'nomessage))

    (straight-use-package 'org)
    (straight-use-package 'use-package)
    (setq straight-use-package-by-default t)

    (use-package selectrum
    :commands selectrum-next-candidate selectrum-previous-candidate
    :hook
    (after-init . selectrum-mode))
    (use-package consult
    :straight (:host github :repo "minad/consult")
    :init
    :hook (after-init . consult-preview-mode))
    (use-package consult-selectrum)

    (use-package adaptive-wrap
        :hook ((prog-mode text-mode) . adaptive-wrap-prefix-mode))

To reproduce, open an org file with some source blocks inside, then M-x
consult-line. What should happen is a swiper-like search menu should
launch and search through the file. What actually happens is the
font-locking error shown above occurs. The same issue happens in a
latex
file, although I haven't done as much exploration into that. 

Note that this is my first bug report to the emacs mailing list, so
please let me know if there's any other information I can provide!

[0]: https://github.com/minad/consult
[1]: https://github.com/raxod502/selectrum
[2]: https://github.com/minad/consult/issues/65

System information: 

In GNU Emacs 27.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version
3.24.22, cairo version 1.16.0)
 of 2020-08-20 built on buildhw-x86-03.iad2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.12010000
System Description: Fedora 33 (Thirty Three)

Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-
png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no --with-xwidgets --with-modules --with-harfbuzz
 --with-cairo --with-json build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2
 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -Wp,-D_GLIBCXX_ASSERTIONS
 -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-
strong
 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
 -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD JSON PDUMPER GMP

Important settings:
  value of $LANG: en_CA.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8