Subject: bug#70387: - 31.0.50; Warning (yasnippet): Couldn't find [[:space:]]

From: no-control to-edit <[email-masked]>
Date: Fri, 21 Feb 2025 04:03:16 +0000

There has been no response to the bug bug#70387 or the issue reported on
the yasnippet github page on April 12, 2024.

I have created an Ert test for it.

yas-expand in yasnippet-0.14.1.0.20250112.175154 throws warning

p.s. is there a more idiomatic way of checking for warnings in Ert

"⛔ Warning (yasnippet): Couldn’t find:
\"[[:space:]\n]*\\\"[[:space:]\n]*\\\\(\\\\)[[:space:]\n]*\\\"\"\n"

;; rm -rf ~/tmp/yas-test
;; mkdir !$
;; emacs --quick --init-directory=!$ this-file

(require 'package)
(add-to-list 'package-archives '("gnu-devel" . "https://elpa.gnu.org/devel/")
t)
(package-initialize)
(package-refresh-contents)

(package-install 'yasnippet)
(use-package yasnippet)

(defun warning-buffer-contents-no-properties ()
  "Return contents of *Warnings* buffer, without properties"
  (when-let* ((buf (get-buffer "*Warnings*")))
    (with-current-buffer buf
      (buffer-substring-no-properties (point-min) (point-max)))))

(defun my-create-yasnippet-snippets ()
  "Create a snippet called `could-not-find-space'.
      Add it to the group `emacs-lisp-mode'
      Allow `org-mode' to inherit `emacs-lisp-mode' snippets"
  (let* ((snippet-key "could-not-find-space")
    (snippet-content (concat
      " ($1)\n"
      "  \"$0\""))
    (snippet-def (list
          snippet-key
          snippet-content
          nil
          nil
          nil
          nil
          nil))
    (snippet-defs (list snippet-def))
    (mode 'emacs-lisp-mode))

    (yas-define-snippets mode
    snippet-defs)
    (yas--define-parents 'org-mode
    '(emacs-lisp-mode))))

(ert-deftest could-not-find-space ()
  "yas-expand should not throw the warning - Couldn't find [[:space:]]"
  (my-create-yasnippet-snippets)

  (ignore-error
      (kill-buffer "*Warnings"))

  (let ((org-mode-buffer-contents
    (concat
     "#+name: test \n"
     "#+begin_src emacs-lisp\n"
     "     2\n"
     "   could-not-find-space| \n"
     "#+end_src")))

    (with-temp-buffer
      (org-mode)
      (setq org-edit-src-content-indentation 1)
      (yas-minor-mode 1)
      (insert org-mode-buffer-contents)
      (goto-char (point-min))
      (search-forward "|")
      (delete-char -1)
      (call-interactively 'yas-expand)
      (buffer-substring-no-properties (point-min) (point-max))))

  (should (equal (warning-buffer-contents-no-properties)
    nil)))

(ert t)

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.16.0) of 2025-02-21 built on slug
Repository revision: 4411d0de1d5cbf308440982084ad7e15a18efaf2
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: LMDE 6 (faye)

Configured using:
 'configure --with-mailutils --with-modules --with-imagemagick
 --prefix=/home/no-control/local/installs
 --bindir=/home/no-control/local/bin --with-native-compilation
 --with-tree-sitter'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG LCMS2 LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM XRANDR GTK3 ZLIB

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

Major mode: ERT-Results

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: 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:
None found.

Features:
(shadow sort mail-extr emacsbug oc-basic ol-eww eww vtable mule-util
url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect
gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr
pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start
gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 nnoo
parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader range
ol-docview doc-view filenotify jka-compr image-mode exif ol-bibtex
bibtex iso8601 ol-bbdb ol-w3m ol-doi org-link-doi use-package-core
ox-odt rng-loc rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn
nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex ox-icalendar
org-agenda ox-html table ox-ascii ox-publish ox org-attach org-element
org-persist org-id org-refile org-element-ast inline avl-tree generator
org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src
sh-script smie treesit executable ob-comint org-pcomplete pcomplete
org-list org-footnote org-faces org-entities noutline outline
org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table ol
org-fold org-fold-core org-keys oc org-loaddefs thingatpt cal-menu
calendar cal-loaddefs org-compat org-macs format-spec ert-x ert ewoc
warnings edebug debug backtrace find-func color yasnippet pcase cl-extra
help-mode yasnippet-autoloads easy-mmode loaddefs-gen lisp-mnt
radix-tree tar-mode arc-mode archive-mode cus-edit pp cus-start cus-load
wid-edit mm-archive message sendmail yank-media dired dired-loaddefs
rfc822 mml mml-sec epa derived gnus-util time-date mailabbrev gmm-utils
mailheader mm-decode mm-bodies mm-encode mail-utils gnutls
network-stream url-cache url-http url-auth mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm puny compile
text-property-search comint ansi-osc ansi-color ring comp-run
comp-common rx epg rfc6068 epg-config finder-inf package browse-url xdg
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 icons 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 touch-screen 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 oclodb
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames native-compile emacs)

Memory information:
((conses 16 411783 32541) (symbols 48 30614 0)
 (strings 32 124515 6677) (string-bytes 1 3456886) (vectors 16 61641)
 (vector-slots 8 591036 21567) (floats 8 455 85) (intervals 56 787 0)
 (buffers 992 15))