Kungsgeten / yankpad

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

Proposing yankpad-ql #57

Closed akirak closed 4 years ago

akirak commented 4 years ago

This is not an issue with your package at all, but I've found a new way to use yankpad, so I'd like to receive your comment here.

The gist is: You already know org-ql, and you can use the package to select a snippet.

First define the following function:

(require 'dash)
(require 'org-ql)
(require 'yankpad)

(defun yankpad-ql (files query)
  (let ((snippets (-flatten-n 1 (org-ql-select files query
                                  :action #'yankpad-snippets-at-point))))
    (yankpad--run-snippet (assoc (completing-read "Snippet: " snippets) snippets))))

Then you can select and insert a snippet:

(yankpad-ql yankpad-file '(level 2))

I personally find this convenient, because it allows me to maintain snippet files in a distributed manner. I've wanted to keep private snippets in separate files.

What do you think of the idea? Is there anything wrong with this implementation? I'd like to hear your opinion. Thanks.

Kungsgeten commented 4 years ago

Hi! I haven't tried the code you present here. It seems like this will scan all snippets in the file, and not only the ones in the active categories? Otherwise it might be nice to use org-ql for the scanning, for speed purposes. If it isn't for speed, I don't see the problem it solves.

Kungsgeten commented 4 years ago

If you want to include snippets from another file you can have a link to that file as a heading in you yankpad-file. There's an example of this in the README at the top.

akirak commented 4 years ago

Thanks. I will never expect it to be merged into yankpad. I'm just personally using its variant in my config.