diff --git a/.emacs.d/emacs.org b/.emacs.d/emacs.org index be9123f..1eb42cc 100644 --- a/.emacs.d/emacs.org +++ b/.emacs.d/emacs.org @@ -571,7 +571,58 @@ languages. Setting ~Confirm Evaluation~ to ~No~ disables the (add-hook 'org-babel-after-execute-hook 'my/redisplay-org-images) #+end_src +**** Wrap text in blocks +A useful snippet for marking a region and wrapping it in an org block. +Taken from [[http://pragmaticemacs.com/emacs/wrap-text-in-an-org-mode-block/][Pragmatic Emacs]] +#+name: packages +#+BEGIN_SRC emacs-lisp + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; function to wrap blocks of text in org templates ;; + ;; e.g. latex or src etc ;; + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (defun org-begin-template () + "Make a template at point." + (interactive) + (if (org-at-table-p) + (call-interactively 'org-table-rotate-recalc-marks) + (let* ((choices '(("s" . "SRC") + ("e" . "EXAMPLE") + ("q" . "QUOTE") + ("v" . "VERSE") + ("c" . "CENTER") + ("l" . "LaTeX") + ("h" . "HTML") + ("a" . "ASCII"))) + (key + (key-description + (vector + (read-key + (concat (propertize "Template type: " 'face 'minibuffer-prompt) + (mapconcat (lambda (choice) + (concat (propertize (car choice) 'face 'font-lock-type-face) + ": " + (cdr choice))) + choices + ", "))))))) + (let ((result (assoc key choices))) + (when result + (let ((choice (cdr result))) + (cond + ((region-active-p) + (let ((start (region-beginning)) + (end (region-end))) + (goto-char end) + (insert "#+END_" choice "\n") + (goto-char start) + (insert "#+BEGIN_" choice "\n"))) + (t + (insert "#+BEGIN_" choice "\n") + (save-excursion (insert "#+END_" choice)))))))))) + + ;;bind to key + (define-key org-mode-map (kbd "C-<") 'org-begin-template) +#+END_SRC *** LaTeX **** AUCTeX #+name: packages