Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

src tag not respected? #68

Closed TRSx80 closed 4 years ago

TRSx80 commented 4 years ago

Hi Kungsgeten,

Thanks for sharing yankpad!

I can't seem to get inserting source blocks to work. I was even able to reproduce the problem in a clean environment (emacs -q).

Say I have the following in yankpad.org (minimal example of the actual exact problem on my machine):

* sh-mode
** conditional short form                                     :src:

N.B.: If =do-if-cond-true= exits nonzero, =do-if-cond-false= will still get executed!

#+BEGIN_SRC shell
[[ cond ]] && do-if-cond-true || do-if-cond-false
#+END_SRC

If I am in sh-mode and I try to insert that with yankpad-insert, I get the whole entry, instead of just the source block.

My understanding was that, when tagged with src it is only supposed to insert what is inside the source block. Is that correct or am I simply misunderstanding?

I also tried doing yankpad-reload (multiple times), at one point I even re-set it manually (I looked it up and saw it's just a wrapper around setq nil).

There was one other weird thing. At some point I looked at the value of yankpad--active-snippets and it was very long and seemed to have a lot of repeat values. I thought "well, something must have got buggered with the cache" and that's when I started trying to re-set it. Now, when I try to do (C-h v) and look at the value of yankpad--active-snippets from in the same sh-mode buffer, I get some error about "Debugger entered--Lisp error: (scan-error "Containing expression ends prematurely"". I'm not sure what that's about (perhaps an ivy/counsel error?).

I am really scratching my head at this point. Any pointers where else to look would be greatly appreciated.

EDIT: I just remembered that, originally, the following line began with a hyphen (I keep most of my notes in bullet points like this):

-N.B.: If =do-if-cond-true= exits nonzero, =do-if-cond-false= will still get executed!

After reading something more about that in the README, I removed the hyphen. Not sure if this is significant or not.

Kungsgeten commented 4 years ago

Hi! You are correct in that only the source block should be inserted.

I tried your snippet and it works on my config, and also with emacs -q. Which versions of yankpad and org-mode are you using? I believe there's an older version of Yankpad on MELPA stable, and I think it doesn't have the src functionality.

TRSx80 commented 4 years ago

Yep, that was exactly the issue. I was still on old version from melpa-stable. I removed that, installed latest from (regular) melpa, restarted my Emacs, and now it works as expected!

I won't tell you how many times I repeatedly executed yankpad-reload followed by yankpad-insert the other day, each time telling myself "this should just work" yet somehow expecting a different result. :smile: :smile: :smile:

Thanks for the support, mate. Cheers! :beers: