]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
org-mode: add youtube link
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 4 Aug 2015 08:22:38 +0000 (10:22 +0200)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 4 Aug 2015 08:22:38 +0000 (10:22 +0200)
- add headers to org-mode block.
- fix hook for js-mode.

bba.org

diff --git a/bba.org b/bba.org
index 6e6ec219451d2dcef006a5f876a18c0f4ff86d2b..1b86c44c85aa7b93e31482df6301c3798b78f8a3 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -453,6 +453,8 @@ It's worth to use Emacs for org-mode alone.
 [[http://howardism.org/Technical/Emacs/literate-devops.html][Literate DevOps]] and [[http://www.howardism.org/Technical/Emacs/literate-database.html][Literate Database Work]] are only 2 use cases.
 With [[https://github.com/fniessen/org-html-themes.git][org html themes]] it's easy to generate beautiful output.
 
+** org-protocol
+
 Run these commands to make org-protocol work in gnome:
 
 #+BEGIN_SRC sh :eval no :tangle no
@@ -498,7 +500,7 @@ javascript:location.href='org-protocol://capture:/l/'%20+%20encodeURIComponent(l
 
 #+END_SRC
 
-Some initial languages we want org-babel to support
+** Some initial languages we want org-babel to support
 
 #+BEGIN_SRC emacs-lisp
 
@@ -534,7 +536,7 @@ Some initial languages we want org-babel to support
 
 #+END_SRC
 
-Find next and previous =#+BEGIN_SRC sh= block.
+** Find next and previous =#+BEGIN_SRC sh= block.
 Very useful for repetitive literate devops jobs.
 <C-c> <S-n> then <C-c><C-c> and so on.
 
@@ -553,7 +555,7 @@ Very useful for repetitive literate devops jobs.
 
 #+END_SRC
 
-Define some shortcuts to access major org files.
+** Define some shortcuts to access major org files.
 
 #+BEGIN_SRC emacs-lisp
 
@@ -579,7 +581,7 @@ Define some shortcuts to access major org files.
 
 #+END_SRC
 
-Tag tasks with GTD contexts
+** Tag tasks with GTD contexts
 
 #+BEGIN_SRC emacs-lisp
                (setq org-tag-alist '(("@work" . ?b)
@@ -639,7 +641,7 @@ Tag tasks with GTD contexts
 
 #+END_SRC
 
-Define some handy link abbreviations
+** Define some handy link abbreviations
 
 #+BEGIN_SRC emacs-lisp
 
@@ -658,7 +660,7 @@ Define some handy link abbreviations
 
 #+END_SRC
 
-Some clock stuff.
+** Some clock stuff.
 taken from http://doc.norang.ca/org-mode.org
 
 #+BEGIN_SRC emacs-lisp
@@ -872,6 +874,45 @@ taken from http://doc.norang.ca/org-mode.org
 
 #+END_SRC
 
+** youtube links
+
+Thanks to [[http://endlessparentheses.com/embedding-youtube-videos-with-org-mode-links.html][endlessparentheses]]: Youtube makes it pretty simple
+to embed videos, they give you the entire iframe HTML code to use, but
+this wouldn’t really be Emacs if we couldn’t make things just a little
+bit easier.
+
+#+BEGIN_SRC emacs-lisp
+  (defvar yt-iframe-format
+    ;; You may want to change your width and height.
+    (concat "<iframe width=\"440\""
+            " height=\"335\""
+            " src=\"https://www.youtube.com/embed/%s\""
+            " frameborder=\"0\""
+            " allowfullscreen>%s</iframe>"))
+
+  (org-add-link-type
+   "yt"
+   (lambda (handle)
+     (browse-url
+      (concat "https://www.youtube.com/embed/"
+              handle)))
+   (lambda (path desc backend)
+     (cl-case backend
+       (html (format yt-iframe-format
+                     path (or desc "")))
+       (latex (format "\href{%s}{%s}"
+                      path (or desc "video"))))))
+#+END_SRC
+
+To use this, just write your org links in the following way (optionally adding a description).
+
+[[yt:A3JAlWM8qRM]]
+
+When you export to HTML, this will produce that same inlined snippet
+that Youtube specifies. The advantage (over simply writing out the
+iframe) is that this link can be clicked in org-mode, and can be
+exported to other formats as well.
+
 * cfengine
 
 #+BEGIN_SRC emacs-lisp
@@ -1169,8 +1210,8 @@ like these:
                                 )
                ))
 
-  (eval-after-load "json-mode"
-    '(add-hook 'json-mode-hook (lambda() (add-hook 'write-contents-functions
+  (eval-after-load "js-mode"
+    '(add-hook 'js-mode-hook (lambda() (add-hook 'write-contents-functions
                                                    (lambda()
                                                      (save-excursion
                                                        (delete-trailing-whitespace)))