Skip to content

Commit

Permalink
Ignore nil elements
Browse files Browse the repository at this point in the history
`org-element-context' returns nil if there are no elements
in an Org file. Add a check to `org-appear--current-elem'
that prevents it from trying to process nil elements.
  • Loading branch information
awth13 committed May 28, 2021
1 parent 9fcf248 commit 8fbecaf
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions org-appear.el
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ It handles toggling elements depending on whether the cursor entered or exited t
(defun org-appear--current-elem ()
"Return element at point.
Return nil if element is not supported by `org-appear-mode'."
(let* ((elem (org-element-context))
(elem-type (car elem))
(elem-end (- (org-element-property :end elem)
(1- (org-element-property :post-blank elem))))
(elem-ignorep (string= (org-element-property :type elem) "cite")))
(if (and (memq elem-type org-appear-elements)
(< (point) elem-end) ; Ignore post-element whitespace
(not elem-ignorep)) ; Ignore specific elements
elem
nil)))
(when-let ((elem (org-element-context)))
(let ((elem-type (car elem))
(elem-end (- (org-element-property :end elem)
(1- (org-element-property :post-blank elem))))
(elem-ignorep (string= (org-element-property :type elem) "cite")))
(if (and (memq elem-type org-appear-elements)
(< (point) elem-end) ; Ignore post-element whitespace
(not elem-ignorep)) ; Ignore specific elements
elem
nil))))

(defun org-appear--get-parent (elem)
"Return parent element if ELEM is nested inside another valid element."
Expand Down

0 comments on commit 8fbecaf

Please sign in to comment.