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