|
@@ -0,0 +1,25 @@
|
|
|
+;; This buffer is for text that is not saved, and for Lisp evaluation.
|
|
|
+;; To create a file, visit it with ‘C-o’ and enter text in its buffer.
|
|
|
+
|
|
|
+(defun my-org-insert-item-or-heading ()
|
|
|
+ "Insert a new item or heading
|
|
|
+
|
|
|
+Insert a new item if currently on a line that starts an item,
|
|
|
+else insert a new heading.
|
|
|
+"
|
|
|
+
|
|
|
+ (interactive)
|
|
|
+ (beginning-of-line)
|
|
|
+ (skip-chars-forward " \t")
|
|
|
+ (if (or (looking-at "-") (looking-at "+"))
|
|
|
+ ;; this handles the case where we are on a line that starts
|
|
|
+ ;; an item. Ideally, it should detect if we are inside a list,
|
|
|
+ ;; to allow multi-line list elements.
|
|
|
+ (progn
|
|
|
+ (end-of-line)
|
|
|
+ (org-insert-item)
|
|
|
+ )
|
|
|
+ (org-insert-heading-respect-content)))
|
|
|
+
|
|
|
+;; Bind it to something useful
|
|
|
+(global-set-key (kbd "C-c i") 'my-org-insert-item-or-heading)
|