Use org-map-entries for index computation of a post

The index computation of a post can be really slow in a big blog for a
subtree at the bottom of the tree.  This commit implements the index
computation using `org-map-entries` making it much faster for the
average case for a large-ish blog, but slightly slower for the initial
few posts in the blog.
master
Puneeth Chaganti 9 years ago committed by Kaushal Modi
parent b0ba08bebf
commit ede8f47809
  1. 17
      ox-hugo.el

@ -909,19 +909,12 @@ If the point is not in a valid Hugo post subtree, nil is returned."
subtree
(org-hugo--get-valid-subtree)))
(level (org-element-property :level entry))
(index 0))
(index 0)
(current-pos (point)))
(when level
(let ((curr-line (line-number-at-pos))
prev-line)
(catch 'break
(while :infinite
(if (and prev-line
(= curr-line prev-line))
(throw 'break nil)
(setq prev-line curr-line)
(org-backward-heading-same-level 1)
(setq curr-line (line-number-at-pos))
(setq index (1+ index))))))
(org-map-entries
(lambda () (when (< (point) current-pos)
(setq index (1+ index)))) "EXPORT_FILE_NAME<>\"\"")
(cons level index))))))
;;; Interactive functions

Loading…
Cancel
Save