From 0d349e09fefd7866987974ddc18e9865f3dda1aa Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 22 Jun 2021 22:20:50 -0700 Subject: [PATCH] [oni-org] Add simple interactive command to wrap a region in a block --- oni-org/oni-org.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index 8397d67..df7348b 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0621.234907 +;; Version: 2021.0622.201820 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons org-journal) ;; This program is free software; you can redistribute it and/or modify @@ -199,6 +199,19 @@ _l_: Store link ^^ _j_: Journal entry (lambda (a b) (string< (cdr a) (cdr b))))) "\n")))) +(defun oni-org-wrap-region-in-block (block-name beginning end) + "Create a block BLOCK-NAME and wrap the text between BEGINNING and END in there." + (interactive "sName: \nr") + (save-excursion + (goto-char end) + (unless (looking-back (rx "\n") nil) (insert "\n")) + (insert "#+end_" block-name) + (unless (looking-at (rx "\n")) (insert "\n")) + (goto-char beginning) + (unless (looking-back (rx "\n") nil) (insert "\n")) + (insert "#+begin_" block-name) + (unless (looking-at (rx "\n")) (insert "\n")))) + (defalias 'org-dblock-write:oni-backlinks 'oni-org-dblock-write-backlinks) (setq org-catch-invisible-edits 'error)