فهرست منبع

Added insert item function

George Jones 2 ماه پیش
والد
کامیت
d1c65ec03c
1فایلهای تغییر یافته به همراه25 افزوده شده و 0 حذف شده
  1. 25 0
      elisp-public/gmj-insert-item-or-heading.el

+ 25 - 0
elisp-public/gmj-insert-item-or-heading.el

@@ -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)