#+STARTUP: hideblocks #+BEGIN_SRC emacs-lisp ;; Author: Tim Krones (itsjeyd) ;; Date: Jan 14 '15 at 15:03:48Z ;; http://emacs.stackexchange.com/questions/7211/collapse-src-blocks-in-org-mode-by-default (defvar org-blocks-hidden nil) (defun org-toggle-blocks () (interactive) (if org-blocks-hidden (org-show-block-all) (org-hide-block-all)) (setq-local org-blocks-hidden (not org-blocks-hidden))) #+END_SRC #+BEGIN_SRC emacs-lisp ;; Author: John Kitchin ;; Date: 2016 Feb 27 at 02:12:20Z ;; http://emacs.stackexchange.com/questions/20577/org-babel-load-all-languages-on-demand ;; (defadvice org-babel-execute-src-block (around load-language nil activate) "Load language if needed" (let ((language (org-element-property :language (org-element-at-point)))) (unless (cdr (assoc (intern language) org-babel-load-languages)) (add-to-list 'org-babel-load-languages (cons (intern language) t)) (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages)) ad-do-it)) #+END_SRC #+BEGIN_SRC emacs-lisp ;;; ;;; ob-groff.el --- Babel Functions for GNU troff (groff) -*- lexical-binding: t; -*- ;; Copyright (C) 2016 rbenit68 ;; Author: rbenit68 at openmailbox dot org ;; Contributors: ;; Version: 0.1 ;; Keywords: org, babel, source block, groff ;; This file is not part of GNU Emacs. ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;; GNU troff (groff) from org-mode source blocks. ;; ;;; Code: (require 'ob) (defvar org-babel-default-header-args:groff '()) (defvar org-babel-groff-command "groff" "Name of command to use for executing groff code.") (defun org-babel-execute:groff (body params) "Execute a block of groff code. This function is called by `org-babel-execute-src-block'." (let* ((out-file (cdr (assoc :file params))) (format (or (and out-file (string-match ".+\\.\\(.+\\)" out-file) (match-string 1 out-file)) "pdf")) (cmdline (cdr (assoc :cmdline params))) (in-file (org-babel-temp-file "groff-")) (cmd (concat "groff " " -Tpdf " cmdline " " (org-babel-process-file-name in-file) (if out-file (concat " > " (org-babel-process-file-name out-file)) ) ))) (with-temp-file in-file (insert (org-babel-expand-body:generic body params ))) (message cmd) (shell-command cmd) nil)) ;; signal that output has already been written to file (defun org-babel-prep-session:groff (_session _params) "Return an error if the :session header argument is set. groff does not support sessions." (error "groff sessions are nonsensical")) (provide 'ob-groff) ;;; ob-groff.el ends here #+end_src #+BEGIN_SRC emacs-lisp ;; Author: Nicholas Van Horn ;; Date: 2016, last seen: Mar 23 '16 21:45CET ;; http://nicholasvanhorn.com/posts/org-structure-completion.html ;;(eval-after-load 'org ;; '(progn (add-to-list 'org-structure-template-alist '("g" "#+BEGIN_SRC groff :file foo.pdf :cmdline -Dutf-8 \n?\n#+END_SRC" "\n\n")) ;; ) ;;) #+END_SRC #+BEGIN_SRC groff :file letter.pdf :cmdline -Dutf-8 -mom .AUTHOR "RBYannick P. Guique" .DOCTYPE LETTER .PRINTSTYLE TYPESET .START .sp 2in .FROM .RIGHT .Y.P. GUIQUE .022 Umask Road .St-Sauveur-en-dehors-de-la-mappe, Québec .TO .GUILLAUME BARRIÈRES .Minidoux Corporation .5000 Pannes Drive .Redmond, Virginia .DATE .RIGHT August 25, 2004 .GREETING Dear Mr. Barrières, .PP It has come to my attention that you have been lobbying the US government to prohibit the use of open source software by endeavouring to outlaw so-called "warranty free" applications. .PP I feel it is my duty to inform you that the success of your operating system with its embedded web browser relies heavily on open source programs and protocolS, Most notably TCP/IP. .PP Therefore, in the interests of your corporation's fiscal health, I strongly advise that you withdraw support for any US legislation that would cripple or render illegal open source development. .CLOSING Sincerely, #+END_SRC #+BEGIN_SRC groff :file header.pdf :cmdline -Dutf-8 -mom .de PP .sp .ti +0.25i .ft R .. .de HD .sp .ps \\$1 .ce .ft B \\$2 .ps .ft P .sp .. .sp 0.67i .HD 14 "A sample header" .PP We begin the text of the first paragraph here. This is indented and formatted. We continue with the text of the first paragraph until we want the second paragraph. .PP We re-issue the macro, and get the space and indent. #+end_src #+BEGIN_SRC groff :file lettermm.pdf :cmdline -Dutf-8 -mm .WA "Christopher T. Craft" 999 Anyway Way Anytown, UT 84111 USA .WE .IA John W. Doe 111 Notown Blvd. Notown, UT 84111 .IE .LO RN "Our telephone conversation" .LO SA "Dear Mr. Doe:" .LT In reference to our telephone conversation on the 4th, I am calling to confirm our upcoming appointment on the 18th. I look forward to discussing the merger. I believe we have a win-win situation here. .FC "Yours Truly," .SG #+END_SRC #+BEGIN_SRC groff :file memo.pdf :cmdline -Dutf-8 -mm .TL Merger Technical Specifications .AF "ABC Corporation" .AU "Christopher Craft" .AT "President" .AS This memo details the specifications for the planned merger. .AE .MT "Merger Description and Marching Orders" As a result of our talks with XYZ corporation, we plan to go forward with the merger. This document contains the following: .BL .LI Schedule and time tables. .LI Financial statements. .LI Asset allocations. .LE .SP Please add any corrections you have, then sign the approval line indicated at the bottom of this sheet. .FC .SG .AV "John W. Doe, XYZ Corporation President" .AV "Sylvia Q. Public, XYZ Corporation CFO" .NS Everyone in the corporation. .NE #+END_SRC #+BEGIN_SRC groff :file equation.pdf :cmdline -Dutf-8 -mm -e .EQ a ~ mark = ~ 30 .EN .sp .EQ a sup 2 ~ + ~ b sup 2~lineup = ~ 1000 .EN .sp .EQ x sup 3 ~ + ~ y sup 3 ~ + ~ z sup 3~lineup = ~ 1400 .EN #+END_SRC #+BEGIN_SRC groff :file table.pdf :cmdline -Dutf-8 -mm -t .TS center, box, tab(:); c s s c | c | c l | l | l. Mergers and Acquisitions Team = Employee:Title:Location =_ Jones, James:Marketing Manager:New York Office Smith, Charles:Sales Manager:Los Angeles Office Taylor, Sarah:R&D Manager:New York Office Walters, Mark:Information Systems Manager:Salt Lake City Office Zur, Mike:Distribution Manager:Portland Office .TE #+END_SRC