Advertisement
Guest User

emacs functions for youtube wrapping

a guest
Feb 10th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.66 KB | None | 0 0
  1. (define-skeleton kjs/youtube-embed
  2.   "Wraps a youtube code with an embed iframe."
  3.   ""
  4.   "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/" _ "\" frameborder=\"0\" allowfullscreen></iframe>" )
  5.  
  6. (defun kjs/youtube-convert ()
  7.   (interactive)
  8.   (re-search-forward "^http.://.*youtube.*v=")
  9.   (let (p1 p2 myLine code)
  10.          (setq p1 (line-beginning-position) )
  11.          (setq p2 (line-end-position) )
  12.          (setq myLine (buffer-substring-no-properties p1 p2))
  13.          (setq code (replace-regexp-in-string ".*v=" "" myLine))
  14.          (forward-line 2)
  15.          (kjs/youtube-embed)
  16.          (insert code)
  17.          (beginning-of-line)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement