about summary refs log tree commit diff stats
path: root/.emacs.d/lisp/init-org.el
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2022-04-28 06:59:12 +0100
committerDavid Morgan <djm_uk@protonmail.com>2022-04-28 06:59:12 +0100
commit0f241204d0a4e2a4db9059d79ee8d93789f9dd65 (patch)
treed3ee7799334c4eee5aa53ab46ad63b2256ee6ba0 /.emacs.d/lisp/init-org.el
parentc125c64013f364318ea9ebfe497833e79281c6f6 (diff)
downloaddotfiles-0f241204d0a4e2a4db9059d79ee8d93789f9dd65.tar.gz
Add functions for formatting text in org mode
Diffstat (limited to '.emacs.d/lisp/init-org.el')
-rw-r--r--.emacs.d/lisp/init-org.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/.emacs.d/lisp/init-org.el b/.emacs.d/lisp/init-org.el
index a1ae5c4..a5f0e24 100644
--- a/.emacs.d/lisp/init-org.el
+++ b/.emacs.d/lisp/init-org.el
@@ -5,12 +5,37 @@
 
 (use-package org
   :ensure nil
+  :init
+  ;; TODO - can we do this with sp-wrap-with-pair?
+  (defmacro define-org-wrap (name char)
+    (let ((cmd (intern (concat "org-" name))))
+      `(defun ,cmd
+           ()
+         (interactive)
+         (if (use-region-p)
+             (let ((re (region-end))
+                   (rb (region-beginning)))
+               (goto-char re)
+               (insert ,char)
+               (goto-char rb)
+               (insert ,char))
+           (beginning-of-thing 'symbol)
+           (insert ,char)
+           (end-of-thing 'symbol)
+           (insert ,char)))
+      `(bind-key ,(concat "C-c " (char-to-string char)) ',cmd org-mode-map)))
   :custom
   (org-log-done t)
   (org-special-ctrl-k t)
   (org-special-ctrl-a t)
   :config
   (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
+  (define-org-wrap "underline" ?_)
+  (define-org-wrap "bold" ?*)
+  (define-org-wrap "italic" ?/)
+  (define-org-wrap "verbatim" ?=)
+  (define-org-wrap "code" ?~)
+  (define-org-wrap "strike-through" ?+)
   :bind
   ("C-c l" . org-store-link)
   ("C-c a" . org-agenda)