Speed-up `org-insert-heading'
* lisp/org.el (org-insert-heading): Refactor to use `org-in-item-p' only once.
This commit is contained in:
parent
3799de774e
commit
cb42a48a30
11
lisp/org.el
11
lisp/org.el
|
@ -7496,22 +7496,23 @@ When INVISIBLE-OK is set, stop at invisible headlines when going back.
|
|||
This is important for non-interactive uses of the command."
|
||||
(interactive "P")
|
||||
(if (org-called-interactively-p 'any) (org-reveal))
|
||||
(let ((itemp (org-in-item-p)))
|
||||
(cond
|
||||
((or (= (buffer-size) 0)
|
||||
(and (not (save-excursion
|
||||
(and (ignore-errors (org-back-to-heading invisible-ok))
|
||||
(org-at-heading-p))))
|
||||
(or arg (not (org-in-item-p)))))
|
||||
(or arg (not itemp))))
|
||||
(insert
|
||||
(if (org-previous-line-empty-p) "" "\n")
|
||||
(if (org-in-src-block-p) ",* " "* "))
|
||||
(run-hooks 'org-insert-heading-hook))
|
||||
((or arg
|
||||
(and (not (org-in-item-p)) org-insert-heading-respect-content)
|
||||
(and (not itemp) org-insert-heading-respect-content)
|
||||
(not (org-insert-item
|
||||
(save-excursion
|
||||
(and (org-in-item-p)
|
||||
(org-beginning-of-item)
|
||||
(and itemp
|
||||
(goto-char itemp)
|
||||
(looking-at org-list-full-item-re)
|
||||
(match-string 3))))))
|
||||
(let (begn endn)
|
||||
|
@ -7654,7 +7655,7 @@ This is important for non-interactive uses of the command."
|
|||
(hide-subtree)))
|
||||
(when (and begn endn)
|
||||
(narrow-to-region (min (point) begn) (max (point) endn)))
|
||||
(run-hooks 'org-insert-heading-hook))))))
|
||||
(run-hooks 'org-insert-heading-hook)))))))
|
||||
|
||||
(defun org-get-heading (&optional no-tags no-todo)
|
||||
"Return the heading of the current entry, without the stars.
|
||||
|
|
Loading…
Reference in New Issue