Kungsgeten / yankpad

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

No org-mode src-block at start of snippet #70

Closed TRSx80 closed 4 years ago

TRSx80 commented 4 years ago

Hi Kungsgeten,

Hope you are well.

The examples in README.org as well as this article both show Orgmode source blocks with newlines above and below (and this is also how I keep my own, for neatness sake). However trying to execute a snippet that is formatted in this way (via results tag) produces the error in title. The solution I found, is to remove the space between the source block and the title. It seems to me this is not intended, so I wanted to file an issue.

Here is the error:

Debugger entered--Lisp error: (error "No org-mode src-block at start of snippet")
  signal(error ("No org-mode src-block at start of snippet"))
  error("No org-mode src-block at start of snippet")
  yankpad--trigger-snippet-function("ISO date" "\n#+begin_src emacs-lisp\n  (format-time-string \"%Y-%m-%d\")\n#+end_src")
  yankpad--run-snippet(("ISO date" ("results") nil "\n#+begin_src emacs-lisp\n  (format-time-string \"%Y-%m-%d\")\n#+end_src" nil))
  yankpad-insert-from-current-category()
  yankpad-insert()
  funcall-interactively(yankpad-insert)
  call-interactively(yankpad-insert nil nil)
  command-execute(yankpad-insert)

Here is the snippet (this does not work):

* org-mode
** ISO date                                       :results:

#+begin_src emacs-lisp
  (format-time-string "%Y-%m-%d")
#+end_src

** next heading

Here is the modified snippet (I only removed the newline) (this does work):

* org-mode
** ISO date                                       :results:
#+begin_src emacs-lisp
  (format-time-string "%Y-%m-%d")
#+end_src

** next heading

I spent a few minutes trying to track down exactly where this was happening, so I could submit a PR, but I am afraid I am not familiar enough with the code (yet) and I don't have any more time for it today. I did want to at least lodge this issue however.

Cheers! :beers:

Kungsgeten commented 4 years ago

Thanks! I haven't used the result and func tags very much. It should be fixed now. It now also allows for plain text before the src block, if you want to write comments etc. A better way would probably be to join all src blocks in the snippet, which would allow for litterate programming, but I think this will do :)

TRSx80 commented 4 years ago

You know, given your comment, I can't help but wonder if you use something more powerful (i.e., yasnippet, skeleton) in cases where you require more functionality?

I'm still trying to squeeze all I can out of yasnippet (and I love it), but I'm getting to a point in my usage where sometimes I think about such things. :smile:

Kungsgeten commented 4 years ago

Actually I don't use snippets that much. Yankpad started because I had a bunch of template text that I used for grading exercises for work (I'm a teacher). Basically like a clipboard with multiple things saved. Then I realised that a thing I didn't like about Yasnippet was every snippet having their own file, and to me it was hard to get an overview of things and understand how they worked. Because of that I integrated Yasnippet functionality into Yankpad. Some of the functionality Yankpad provide (like func and result) was ideas of what would be possible to do, so more of a solution looking for a problem than the other way around ;)

For the snippets I do use I fully use Yankpad, but mostly its most basic functionality.

Kungsgeten commented 4 years ago

What kind of functionality do you feel is lacking, btw?

TRSx80 commented 4 years ago

What kind of functionality do you feel is lacking, btw?

I think I was trying to include one snippet into another one. Which is supported in vanilla Org / Babel (by naming the source blocks), but I could not seem to get it working in yankpad.

I realize it may be out of scope, and doesn't sound like it's something you would even use, otherwise I may have created a separate issue. But since you asked. :smile:

If you care to pursue it, I could open separate issue, with an example, etc.

If not, that's fine too. Maybe I get around to it myself one day (but it's probably pretty far down the list -- until one day I need it again :smile: ).

Or maybe we make separate issue just to track status of, until one of us get around to it? I am fine with whatever. In fact I appreciate your engagement.

Like you, I also really prefer the workflow of keeping everything organized in an Org file (as I am similarly a heavy Org user).

Kungsgeten commented 4 years ago

Sure, feel free to open an issue. It would be nice to see the use case for the functionality.