Skip to content

Warning Couldn't find space #1197

@dericbytes

Description

@dericbytes

I get 'Warning Couldn't find space' when expanding yas snippets in org src blocks.

I opened an issue in 2019 #976 and it eased the problem. However it never solved it. At the time I tried it on a fresh system but could not reproduce it. I assumed it was due to my complex setup.

I have managed to replicate it on a clean build. I stripped away as much as I could.

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-03
yasnippet 2024 - Version: 0.14.1

rm -rf ~/tmp/yas-test
mkdir !$
emacs --quick --init-directory=!$ !$/test.org
M-x package-install yasnippet
M-x yas-new-snippet
# key: di
# name: di
# --
 ($1)
  "$0"

save as emacs lisp snippet

C-c C-c
> emacs-lisp-mode
> RET
> y

Get emacs-lisp snippets to work in org-mode

M-x find-file snippets/org-mode/.yas-parents

add the text

emacs-lisp-mode

and save file.

In test.org add the code below, note there is an indent of a space before the #'s

 #+name: test
 #+begin_src emacs-lisp
      2
    di
  #+end_src
M-x yas-minor-mode
M-x yas-reload-all

place cursor after

di

and press TAB

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions