0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 19:37:52 +00:00

Speed improvement

* lisp/org.el (org-get-previous-line-level): Do not call
  `org-current-level' twice unless necessary.  Also, avoid using
  `line-number-at-pos' when the information needed is to know if point
  is in the first line of the visible part of the buffer.
This commit is contained in:
Nicolas Goaziou 2014-01-10 11:22:49 +01:00
parent 432decf725
commit 8720c49807

View file

@ -7887,14 +7887,10 @@ The level is the number of stars at the beginning of the headline."
"Return the outline depth of the last headline before the current line.
Returns 0 for the first headline in the buffer, and nil if before the
first headline."
(let ((current-level (org-current-level))
(prev-level (when (> (line-number-at-pos) 1)
(save-excursion
(beginning-of-line 0)
(org-current-level)))))
(cond ((null current-level) nil) ; Before first headline
((null prev-level) 0) ; At first headline
(prev-level))))
(and (org-current-level)
(or (and (/= (line-beginning-position) (point-min))
(save-excursion (beginning-of-line 0) (org-current-level)))
0)))
(defun org-reduced-level (l)
"Compute the effective level of a heading.