Subject: 29.1.50; adaptive-wrap: wrong prefix added in commented lines in latex-mode buffers

From: Ramon Diaz-Uriarte <[email-masked]>
Date: Sat, 14 Oct 2023 15:11:26 +0200

With adaptive-wrap, in a LaTeX-mode buffer, commented out lines that start with a "-" or a "*" get those symbols at the start of each of the wrapped lines. That does not happen with other symbols such as "+" or "=".

The desired behavior would be to only have the percentage sign plus some whitespace added to the wrapped lines. For example as in  https://github.com/luisgerhorst/virtual-auto-fill/blob/master/README-screenshot-virtual-auto-fill.png

This was originally reported for the "virtual-auto-fill" package: https://github.com/luisgerhorst/virtual-auto-fill/issues/3
As commented there, this might be hard to fix; maybe the "%" could be detected as special (a comment char), and the magic list processing added on top of that.

Steps to reproduce:

- Start emacs with emacs -Q

- Evaluate
  (require 'package)
  (package-initialize)
  (use-package adaptive-wrap)

- Create a new tex buffer and ensure it is in latex mode

- Type some suitable long text in a single line with "%%" as first character (comment),  then a space, then a "-". For example:

  %% - aaaaa eeeee iiiii ooooo uuuuu aaaaa eeeee iiiii ooooo uuuuu aaaaa eeeee iiiii ooooo uuuuu aaaaa eeeee iiiii ooooo uuuuu aaaaa eeeee iiiii ooooo uuuuu

- Enable adaptive-wrap-prefix-mode

- Modify window size so the text is displayed in multiple lines.

- Change the "-" by a "*", a "+", a "=".

In GNU Emacs 29.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2023-10-07 built on Triturus
Repository revision: 247743bd1e99821e111a838ca5070c5ba057ac1c
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure --disable-silent-rules --with-native-compilation=aot
 --with-json --with-xwidgets --without-xaw3d --with-x-toolkit=gtk3
 --prefix=/home/ramon/Sources/emacs29-bin 'CFLAGS=-g -O2 -mtune=native
 -march=native' 'CC=ccache gcc''

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

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

Major mode: mu4e:headers

Minor modes in effect:
  windmove-mode: t
  ivy-rich-mode: t
  which-key-mode: t
  flx-ido-mode: t
  pdf-occur-global-minor-mode: t
  mu4e-search-minor-mode: t
  mu4e-update-minor-mode: t
  mu4e-context-minor-mode: t
  mu4e-modeline-mode: t
  helm-mode: t
  helm-minibuffer-history-mode: t
  helm-ff-icon-mode: t
  shell-dirtrack-mode: t
  async-bytecomp-package-mode: t
  hl-line-mode: t
  company-box-mode: t
  company-prescient-mode: t
  global-company-mode: t
  company-mode: t
  vertico-multiform-mode: t
  vertico-mode: t
  shackle-mode: t
  beacon-mode: t
  global-hl-todo-mode: t
  global-aggressive-indent-mode: t
  winner-mode: t
  show-smartparens-global-mode: t
  smartparens-global-mode: t
  which-function-mode: t
  global-auto-revert-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/ramon/.emacs.d/elpa/emacsql-sqlite-20230225.2205/emacsql-sqlite hides /home/ramon/.emacs.d/elpa/emacsql-20230417.1448/emacsql-sqlite
/home/ramon/.emacs.d/elpa/transient-20230919.2146/transient hides /home/ramon/Sources/emacs29-bin/share/emacs/29.1.50/lisp/transient
/home/ramon/.emacs.d/elpa/modus-themes-20230926.1524/theme-loaddefs hides /home/ramon/Sources/emacs29-bin/share/emacs/29.1.50/lisp/theme-loaddefs

Features:
(shadow emacsbug add-log pdf-sync pdf-outline pdf-links pdf-history
image-file image-converter helm-external helm-net ffap misearch
multi-isearch goto-addr ess-julia julia-mode julia-mode-latexsubs
ess-r-mode ess-r-flymake flymake-proc flymake ess-r-xref ess-trns
ess-r-package ess-r-completion ess-roxy ess-r-syntax ess-rd ess-s-lang
ess-help ess-mode ess-inf ess-tracebug smartparens-ess ess lisp-mnt
ess-utils ess-custom smex windmove url-queue url-cache epa-file
network-stream mailalias executable nerd-icons nerd-icons-faces
nerd-icons-data nerd-icons-data-mdicon nerd-icons-data-flicon
nerd-icons-data-codicon nerd-icons-data-devicon nerd-icons-data-sucicon
nerd-icons-data-wicon nerd-icons-data-faicon nerd-icons-data-powerline
nerd-icons-data-octicon nerd-icons-data-pomicon nerd-icons-data-ipsicon
elec-pair flyspell-correct-helm flyspell-correct flyspell ispell
writegood-mode face-remap tramp-archive tramp-gvfs tramp-cache
time-stamp zeroconf rdu-miscell-funcs url-http url-auth url-gw nsm
shr-color sort gnus-cite smiley mm-archive mail-extr qp textsec
uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check
virtual-auto-fill visual-fill-column adaptive-wrap counsel xref project
swiper ivy-rich ivy delsel ivy-faces ivy-overlay colir color which-key
flx-ido flx modus-vivendi-theme gnus-dired mu4e mu4e-org
org-protocol-capture-html org-protocol org-agenda org-noter-pdftools
org-pdftools pdf-occur ibuf-ext ibuffer ibuffer-loaddefs pdf-isearch
let-alist pdf-annot tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local cedet facemenu
pdf-misc org-noter org-noter-pdf org-noter-core pdf-tools compile
cus-edit cus-start pdf-view jka-compr pdf-cache pdf-info tq pdf-util
pdf-macs org-element org-persist org-id avl-tree generator org-refile
org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src
ob-comint org-pcomplete org-list org-footnote org-faces org-entities
ob-emacs-lisp ob-core ob-eval org-cycle org-table ol org-fold
org-fold-core org-keys oc org-loaddefs org-version org-compat org-macs
mu4e-notification notifications mu4e-main mu4e-view gnus-art mm-uu
mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo
gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo
gnus-spec gnus-int gnus-range gnus-win gnus nnheader range wid-edit
cal-menu calendar cal-loaddefs mu4e-headers mu4e-compose mu4e-draft
mu4e-actions smtpmail mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark
mu4e-message shr pixel-fill kinsoku url-file svg xml flow-fill mule-util
mu4e-contacts mu4e-update mu4e-folders mu4e-context mu4e-query-items
mu4e-server mu4e-modeline mu4e-vars mu4e-helpers mu4e-config mu4e-window
bookmark pp ido message sendmail yank-media puny helm-mode helm-misc
helm-files image-dired image-dired-tags image-dired-external
image-dired-util xdg image-mode exif tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat shell pcomplete comint ansi-osc
parse-time iso8601 helm-buffers helm-occur helm-tags helm-locate
helm-grep helm-regexp format-spec helm-utils helm-help helm-types helm
helm-global-bindings helm-core async-bytecomp helm-source
helm-multi-match helm-lib async dired-hide-permissions dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util text-property-search time-date mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev gmm-utils mu4e-obsolete hl-line noutline outline hideshow
display-fill-column-indicator rainbow-delimiters company-box
company-box-doc frame-local company-box-icons all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons company-abbrev
company-dabbrev-code company-dabbrev company-keywords company-files
company-reftex reftex-cite reftex reftex-loaddefs reftex-vars
company-math math-symbol-lists company-capf company-prescient prescient
char-fold company pcase rdu-emacs-fonts-funcs-0 vertico-multiform
vertico flycheck-grammarly grammarly websocket bindat request mailheader
mail-utils s dom exec-path-from-shell flycheck ansi-color find-func
shackle trace beacon hl-todo compat modus-operandi-theme modus-themes
aggressive-indent hydra lv pdf-loader winner ring smartparens-config
smartparens-text smartparens advice thingatpt dash cl edmacro kmacro
use-package-bind-key use-package-ensure use-package-core comp comp-cstr
warnings icons rx cl-extra help-mode which-func imenu autorevert
filenotify time cus-load bind-key easy-mmode finder-inf info
ace-jump-zap-autoloads ace-jump-mode-autoloads ace-link-autoloads
ace-window-autoloads ag-autoloads aggressive-indent-autoloads
all-the-icons-autoloads anki-editor-autoloads anzu-autoloads
avy-autoloads beacon-autoloads bicycle-autoloads buffer-move-autoloads
burly-autoloads citar-embark-autoloads citar-autoloads
citeproc-autoloads company-auctex-autoloads auctex-autoloads tex-site
company-box-autoloads company-math-autoloads company-prescient-autoloads
company-reftex-autoloads consult-autoloads counsel-autoloads
default-text-scale-autoloads deft-autoloads dumb-jump-autoloads
dwim-shell-command-autoloads ebib-autoloads eglot-jl-autoloads
ein-autoloads anaphora-autoloads elisp-demos-autoloads
emacsql-sqlite-autoloads embark-autoloads ess-autoloads esup-autoloads
exec-path-from-shell-autoloads expand-region-autoloads flx-ido-autoloads
flx-autoloads flycheck-grammarly-autoloads flycheck-autoloads
flymd-autoloads flyspell-correct-helm-autoloads
flyspell-correct-autoloads fold-dwim-autoloads frame-local-autoloads
git-timemachine-autoloads grammarly-autoloads haskell-mode-autoloads
helm-ag-autoloads helm-bibtex-autoloads bibtex-completion-autoloads
biblio-autoloads biblio-core-autoloads helm-company-autoloads
company-autoloads helm-descbinds-autoloads helm-mu-autoloads
helm-easymenu helm-rg-autoloads helm-swoop-autoloads helpful-autoloads
elisp-refs-autoloads hide-mode-line-autoloads
highlight-indent-guides-autoloads highlight-symbol-autoloads
hl-todo-autoloads hydra-autoloads ido-vertical-mode-autoloads
iedit-autoloads imenu-anywhere-autoloads ivy-rich-autoloads
julia-mode-autoloads julia-repl-autoloads jump-char-autoloads
jupyter-autoloads lsp-ui-autoloads lsp-mode-autoloads ht-autoloads
f-autoloads lv-autoloads magit-autoloads git-commit-autoloads
marginalia-autoloads markdown-toc-autoloads math-symbol-lists-autoloads
memoize-autoloads mixed-pitch-autoloads modus-themes-autoloads
multiple-cursors-autoloads nerd-icons-autoloads orderless-autoloads
org-attach-screenshot-autoloads org-bullets-autoloads
org-download-autoloads org-fragtog-autoloads org-roam-ui-autoloads
org-roam-autoloads magit-section-autoloads emacsql-autoloads
org-superstar-autoloads parsebib-autoloads pdf-tools-autoloads
pdfgrep-autoloads pkg-info-autoloads epl-autoloads poly-R-autoloads
poly-markdown-autoloads markdown-mode-autoloads poly-noweb-autoloads
polymode-autoloads posframe-autoloads prescient-autoloads
projectile-autoloads queue-autoloads rainbow-delimiters-autoloads
rg-autoloads rotate-autoloads s-autoloads sage-shell-mode-autoloads
shackle-autoloads simple-httpd-autoloads smartparens-autoloads
smex-autoloads spinner-autoloads stream-autoloads
string-inflection-autoloads swap-buffers-autoloads swiper-helm-autoloads
helm-autoloads popup-autoloads helm-core-autoloads async-autoloads
swiper-autoloads ivy-autoloads tablist-autoloads transient-autoloads
transpose-frame-autoloads vertico-autoloads virtual-auto-fill-autoloads
adaptive-wrap-autoloads visual-fill-column-autoloads vterm-autoloads
websocket-autoloads wfnames-autoloads wgrep-ag-autoloads wgrep-autoloads
which-key-autoloads whole-line-or-region-autoloads winum-autoloads
dash-autoloads with-editor-autoloads compat-autoloads
workgroups2-autoloads writegood-mode-autoloads yasnippet-autoloads
zmq-autoloads zotxt-autoloads deferred-autoloads request-autoloads
ztree-autoloads package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs password-cache json subr-x map byte-opt gv bytecomp
byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 1247130 253754)
 (symbols 48 55618 96)
 (strings 32 298879 237018)
 (string-bytes 1 10682142)
 (vectors 16 122505)
 (vector-slots 8 3235350 340780)
 (floats 8 5817 889)
 (intervals 56 38997 5020)
 (buffers 984 66))