[oni-org] Add simple interactive command to wrap a region in a block
This commit is contained in:
parent
8a0e2a326d
commit
0d349e09fe
1 changed files with 14 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||
;; 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)
|
||||
|
|
Loading…
Reference in a new issue