mirror of
https://github.com/correl/dotfiles.git
synced 2024-11-16 11:09:29 +00:00
Wrap text in org blocks
This commit is contained in:
parent
b8f9498760
commit
dbd3a39d4d
1 changed files with 51 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue