GNU bug report logs - #70387
30.0.50; 'Warning Couldn't find space' when expanding Yasnippet snippet within an org-mode source block.

Previous Next

Package: emacs;

Reported by: Deric Bytes <dericbytes <at> gmail.com>

Date: Sun, 14 Apr 2024 19:48:03 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 70387 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70387; Package emacs. (Sun, 14 Apr 2024 19:48:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Deric Bytes <dericbytes <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 14 Apr 2024 19:48:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Deric Bytes <dericbytes <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; 'Warning Couldn't find space' when expanding Yasnippet
 snippet within an org-mode source block.
Date: Sun, 14 Apr 2024 20:46:53 +0100
[Message part 1 (text/plain, inline)]
Start with a clean Emacs.

#+begin_src shell :results silent
  rm -rf ~/tmp/yas-test
  mkdir !$
  emacs --quick --init-directory=!$ !$/test.org
#+end_src

Add Yasnippet.

#+begin_src emacs-lisp :results silent
  (use-package yasnippet
           :ensure t)
#+end_src

Use this yasnippet snippet.

#+name: snippet1
#+begin_example quote
# key: di
# name: di
# --
($1)
"$0"
#+end_example

Save snippet in an emacs-lisp-mode group

#+begin_src emacs-lisp :var snippet=snippet1 :results silent
  (make-directory "~/tmp/yas-test/snippets/emacs-lisp-mode" t)
  (find-file "~/tmp/yas-test/snippets/emacs-lisp-mode/di")
  (insert snippet)
  (save-buffer)
  (kill-buffer)
#+end_src

Get emacs-lisp snippets to work in org-mode by adding .yas-parents

#+begin_src emacs-lisp :results silent
(let ((dir "~/tmp/yas-test/snippets/org-mode")
       (file ".yas-parents"))
    (make-directory dir)
    (find-file (expand-file-name file dir))
    (insert "emacs-lisp-mode")
    (save-buffer)
    (kill-buffer (current-buffer)))
#+end_src

In a file with `org-mode' active.
add the following source block
note there is an indent of a space before the #'s

 #+name: test
 #+begin_src emacs-lisp
 2
 di
 #+end_src

GOTCHA:
I used this file to run the tests
I did an indent-buffer and lost the extra
space before the test source block.
The expansion works when no indent.

Activate Yasnippet in the test org buffer.

#+begin_src emacs-lisp :results silent
  (yas-minor-mode 1)
#+end_src

 Tell yasnippet about the new emacs-lisp-mode snippet and
 org-mode .yas-parents.

#+begin_src emacs-lisp :results silent
   (yas-reload-all)
#+end_src

place cursor after *di* in source block above and press TAB

#+begin_src text :results code
  ⛔ Warning (yasnippet): Couldn’t find: "[[:space:]
  ]*\"[[:space:]
  ]*\\(\\)[[:space:]
  ]*\""
#+end_src


NOTE:

A collection of things had to be in place to generate this.

Works when:

org source block has no indent i.e. remove space before ' #+'
the source block has no property i.e #+name
the expansion trigger is the only thing in the source block
the expansion trigger is after contents but still on the first line
there is only one snippet variable
all the snippet variables are on same line
the quotes around $0 are removed
the parenthesis around $1 are removed

It does not work when content is above the yas trigger.
i.e. 2 is above the 'di' yas trigger key








In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.0, Xaw3d scroll bars) of 2024-04-14 built on
 no-control-x1c
Repository revision: 3d3602055264ca3095b7f28ca7e27a6f2782649a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Ubuntu 23.10

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

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ IMAGEMAGICK
JPEG 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 XAW3D XDBE XIM
XINPUT2 XPM LUCID ZLIB

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

Major mode: Org

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
  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 two-column kmacro help-fns 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 ert-x ert ewoc warnings edebug
debug backtrace color yasnippet pcase yasnippet-autoloads easy-mmode
loaddefs-gen lisp-mnt radix-tree tar-mode arc-mode archive-mode cus-edit
pp cus-start cus-load mm-archive network-stream url-cache url-http
url-auth url-gw nsm finder-inf package url-handlers use-package-ensure
use-package-core sh-script smie treesit executable org-element
org-persist org-id org-refile avl-tree generator oc-basic cl-extra
help-mode ol-eww eww xdg url-queue thingatpt mm-url ol-rmail ol-mhe
ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime
smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom
gnus-group gnus-undo gnus-start gnus-dbus dbus compile comp-run
comp-common xml gnus-cloud nnimap nnmail browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util url-parse auth-source cl-seq
eieio eieio-core cl-macs json map byte-opt gv bytecomp byte-compile
url-vars mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range
message sendmail mailcap yank-media puny rfc822 mml mml-sec
password-cache epa derived epg rfc6068 epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus nnheader gnus-util
text-property-search mail-utils range mm-util mail-prsvr wid-edit
ol-docview doc-view filenotify jka-compr image-mode exif dired
dired-loaddefs ol-bibtex bibtex iso8601 ol-bbdb ol-w3m ol-doi
org-link-doi org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src ob-comint org-pcomplete pcomplete comint ansi-osc ansi-color
ring org-list org-footnote org-faces org-entities time-date subr-x
noutline outline icons org-version ob-emacs-lisp ob-core ob-eval
org-cycle org-table ol rx org-fold org-fold-core org-keys oc
org-loaddefs find-func cal-menu calendar cal-loaddefs org-compat
org-macs format-spec 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 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 dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo x-toolkit xinput2 x multi-tty move-toolbar make-network-process
native-compile emacs)

Memory information:
((conses 16 591095 113255) (symbols 48 30094 4)
 (strings 32 173018 6038) (string-bytes 1 5053704) (vectors 16 91376)
 (vector-slots 8 1601641 57977) (floats 8 878 363)
 (intervals 56 3503 146) (buffers 992 21))
[Message part 2 (text/html, inline)]

This bug report was last modified 19 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.