Kungsgeten / yankpad

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

cool tip to add to wiki and optimization suggestion needed #37

Closed zeltak closed 3 years ago

zeltak commented 6 years ago

Hi so first ive been using yankpad as a quick way to add, convert and process org-mode code blocks and i love it. i thought that this could be a nice addition to the wiki (i can add it myself if you want and approve)

So what i do is this:

i have yasnippet set to

;; default to wrap 
(setq yas-wrap-around-region t)

then i have the following snippet

*** pbash: paste with clipboard data                                 :key:pb:
#+BEGIN_SRC sh  :results none
$0
#+END_SRC

now i can mark a line region ,activate the snippet and voila the line is wraped in a orgmode block neat :) i extended this to many languages and types of blocks

i also have similar code to paste a already copied to clip text into an org block using yasnippet magic

*** pcbash: paste with clipboard data                                :key:pcb:
#+BEGIN_SRC sh  :results none
`(yank)` $0
#+END_SRC

Finally a question or feedback from anyone. can one modify the first script that of the region is active/selected it would wrap the region as it does currently BUT if nothing is selected it would wrap the current line?

best

Z

Kungsgeten commented 3 years ago

Closing this because of inactivity. I think the last snippet could be optimized with the new support for special properties and som elisp.