lang/org: fix +org/insert-item (org-element-lineage gone?)
This commit is contained in:
parent
8fc3b1941b
commit
c81e0ec0a1
1 changed files with 12 additions and 11 deletions
|
@ -48,10 +48,7 @@ I use this instead of `org-insert-item' or `org-insert-heading' which are too
|
||||||
opinionated and perform this simple task incorrectly (e.g. whitespace in the
|
opinionated and perform this simple task incorrectly (e.g. whitespace in the
|
||||||
wrong places)."
|
wrong places)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((context (org-element-lineage
|
(let* ((context (org-element-context))
|
||||||
(org-element-context)
|
|
||||||
'(table table-row headline inlinetask item plain-list)
|
|
||||||
t))
|
|
||||||
(type (org-element-type context)))
|
(type (org-element-type context)))
|
||||||
(cond ((eq type 'item)
|
(cond ((eq type 'item)
|
||||||
(let ((marker (org-element-property :bullet context)))
|
(let ((marker (org-element-property :bullet context)))
|
||||||
|
@ -69,12 +66,15 @@ wrong places)."
|
||||||
(cl-case direction
|
(cl-case direction
|
||||||
('below (org-table-insert-row t))
|
('below (org-table-insert-row t))
|
||||||
('above (+org/table-prepend-row-or-shift-up))))
|
('above (+org/table-prepend-row-or-shift-up))))
|
||||||
(t
|
((memq type '(headline inlinetask plain-list))
|
||||||
(let ((level (save-excursion
|
(let* ((subcontext (org-element-context))
|
||||||
(org-back-to-heading)
|
(level (save-excursion
|
||||||
(org-element-property
|
(org-back-to-heading)
|
||||||
:level (org-element-lineage (org-element-context)
|
(org-element-property
|
||||||
'(headline) t)))))
|
:level
|
||||||
|
(if (eq (org-element-type subcontext) 'headline)
|
||||||
|
subcontext
|
||||||
|
1)))))
|
||||||
(cl-case direction
|
(cl-case direction
|
||||||
('below
|
('below
|
||||||
(let ((at-eol (= (point) (1- (line-end-position)))))
|
(let ((at-eol (= (point) (1- (line-end-position)))))
|
||||||
|
@ -94,7 +94,8 @@ wrong places)."
|
||||||
(save-excursion (evil-open-above 1))
|
(save-excursion (evil-open-above 1))
|
||||||
(save-excursion (insert "\n")))))
|
(save-excursion (insert "\n")))))
|
||||||
(when (org-element-property :todo-type context)
|
(when (org-element-property :todo-type context)
|
||||||
(org-todo 'todo)))))
|
(org-todo 'todo))))
|
||||||
|
(t (user-error "Not a valid list")))
|
||||||
(evil-append-line 1)))
|
(evil-append-line 1)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue