Fix wrong-type-argument error from +org/insert-item

+org/insert-item would throw "save-excursion: Wrong type argument:
listp, 1" when used from BOL on the first sub-item in a list.
This commit is contained in:
Henrik Lissner 2017-09-03 20:59:52 +02:00
parent c7957c9321
commit 23404980ac
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -146,7 +146,7 @@ wrong places)."
'(table table-row headline inlinetask item plain-list)
t))
(type (org-element-type context)))
(cond ((eq type 'item)
(cond ((memq type '(item plain-list))
(let ((marker (org-element-property :bullet context))
(pad (save-excursion
(back-to-indentation)
@ -157,7 +157,7 @@ wrong places)."
(insert (concat "\n" (make-string pad ? ) marker)))
('above
(goto-char (line-beginning-position))
(insert (make-string pad ? ) marker)
(insert (make-string pad 32) (or marker ""))
(save-excursion (insert "\n")))))
(when (org-element-property :checkbox context)
(insert "[ ] ")))
@ -167,15 +167,13 @@ wrong places)."
('below (org-table-insert-row t))
('above (+org/table-prepend-row-or-shift-up))))
((memq type '(headline inlinetask plain-list))
((memq type '(headline inlinetask))
(let* ((subcontext (org-element-context))
(level (save-excursion
(org-back-to-heading)
(org-element-property
:level
(if (eq (org-element-type subcontext) 'headline)
subcontext
1)))))
(if (eq (org-element-type subcontext) 'headline)
(org-element-property :level subcontext)
1))))
(pcase direction
('below
(let ((at-eol (= (point) (1- (line-end-position)))))