Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't undo snippets #13

Open
jmhammond opened this issue Dec 9, 2019 · 2 comments
Open

Can't undo snippets #13

jmhammond opened this issue Dec 9, 2019 · 2 comments
Labels
needs-triage Issue hasn't been assessed yet
Milestone

Comments

@jmhammond
Copy link

This is actually related to the discussion of #6. When I expand a snippet using doom emacs (via TAB), it presents the snippet perfectly, but I can't undo the expansion of the snippet as #6 reported using the basic undo function.

I tried prettying ESC and C-g many times followed by many instances of undo, but the problem is that the snippet has created an undo branch point. In order to reverse it, we need to M-x undo-tree-visualize and then cursor through until we figure out where we intended to go.

I'm new to doom emacs as of yesterday - I've been using spacemacs with the same yasnippets ofr year (I literally copied over my snippets folder into my .doom.d), and in spacemacs I didn't I have problem using undoing.

Here's a gif of the expansion.

I spent far too many hours on this trying to diagnose the problem (avoiding grading finals...). Do you any advice about what to try?

@jmhammond
Copy link
Author

jmhammond commented Dec 9, 2019

I started thinking that perhaps it was those created with a previous yasnippets was at fault, so I recreated two expansions using M-x +snippets/new.

The first file, test, allows me to undo through its creation.
test

# -*- mode: snippet -*-
# name: test
# uuid: test
# key: tes
# condition: t
# --
<test>
  $0
</test>

This second file, definition2, a recreation of the definition expansion used in the video above, still doesn't let me undo using the standard undo command.
definition2

# -*- mode: snippet -*-
# name: definition2
# uuid: blablbahblabhlabhlbahb
# key: def2
# condition: t
# --
<definition>
  <statement>
    <p>
      $0
    </p>
  </statement>
</definition>

There must be something about the more complex expansion that is the problem.

@jmhammond
Copy link
Author

... one final piece of the puzzle. If I enable, in my init.el file (company +tng) the expansion def2 works just fine.

However, if I have multiple tab-points:

# -*- mode: snippet -*-
# name: definition2
# uuid: blablbahblabhlabhlbahb
# key: def2
# condition: t
# --
<definition>
  <statement>
    <p>
      $1
    </p>
  </statement>
</definition>
$0

I'm able to undo, but only after I tab through every possible location. Without the +tng flag, undo doesn't work, as in the original gif.

As a workaround, I've enabled +tng and I've changed all of my snippets to have only one $0 rather than multiple $n targets.

I'm leaving this open, since there's something to this, but you're welcome to close it if it's not a bug in doom-snippets. Sorry for the comment spam, and thanks for your time!

jmhammond added a commit to jmhammond/doomd that referenced this issue Dec 9, 2019
... per my comments at
doomemacs/snippets#13, having only one
target, $0, rather than $1, $0, I'm able to undo snippet expansion.
That's more important than tabbing through to me.
@hlissner hlissner added this to Triage Apr 21, 2022
@hlissner hlissner moved this to Unreviewed in Triage Apr 21, 2022
@hlissner hlissner added the needs-triage Issue hasn't been assessed yet label May 2, 2022
@hlissner hlissner added this to the Backlog milestone May 2, 2022
@hlissner hlissner removed this from Triage Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Issue hasn't been assessed yet
Projects
None yet
Development

No branches or pull requests

2 participants