[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 399a29c 13/29: org.el/org-up-heading-safe: Add cach
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 399a29c 13/29: org.el/org-up-heading-safe: Add cache support |
Date: |
Sun, 17 Oct 2021 02:57:27 -0400 (EDT) |
branch: externals/org
commit 399a29c4f47bc30e04d213f0224e0a364c9644ed
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org.el/org-up-heading-safe: Add cache support
---
lisp/org.el | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 23 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 196a264..ea43d66 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20698,29 +20698,42 @@ headline found, or nil if no higher level is found.
Also, this function will be a lot faster than `outline-up-heading',
because it relies on stars being the outline starters. This can really
make a significant difference in outlines with very many siblings."
- (when (ignore-errors (org-back-to-heading t))
- (let (level-cache)
- (unless org--up-heading-cache
- (setq org--up-heading-cache (make-hash-table)))
- (if (and (eq (buffer-chars-modified-tick) org--up-heading-cache-tick)
- (setq level-cache (gethash (point) org--up-heading-cache)))
- (when (<= (point-min) (car level-cache) (point-max))
- ;; Parent is inside accessible part of the buffer.
- (progn (goto-char (car level-cache))
- (cdr level-cache)))
- ;; Buffer modified. Invalidate cache.
- (unless (eq (buffer-chars-modified-tick) org--up-heading-cache-tick)
- (setq-local org--up-heading-cache-tick
- (buffer-chars-modified-tick))
- (clrhash org--up-heading-cache))
- (let* ((level-up (1- (funcall outline-level)))
- (pos (point))
- (result (and (> level-up 0)
- (re-search-backward
- (format "^\\*\\{1,%d\\} " level-up) nil t)
- (funcall outline-level))))
- (when result (puthash pos (cons (point) result)
org--up-heading-cache))
- result)))))
+ (if-let ((element (and (org-element--cache-active-p)
+ (org-element-at-point nil t))))
+ (let* ((current-heading (org-element-lineage element '(headline)
'with-self))
+ (parent (org-element-lineage current-heading '(headline))))
+ (if (and parent
+ (<= (point-min) (org-element-property :begin parent)))
+ (progn
+ (goto-char (org-element-property :begin parent))
+ (org-element-property :level parent))
+ (when (and current-heading
+ (<= (point-min) (org-element-property :begin
current-heading)))
+ (goto-char (org-element-property :begin current-heading))
+ nil)))
+ (when (ignore-errors (org-back-to-heading t))
+ (let (level-cache)
+ (unless org--up-heading-cache
+ (setq org--up-heading-cache (make-hash-table)))
+ (if (and (eq (buffer-chars-modified-tick) org--up-heading-cache-tick)
+ (setq level-cache (gethash (point) org--up-heading-cache)))
+ (when (<= (point-min) (car level-cache) (point-max))
+ ;; Parent is inside accessible part of the buffer.
+ (progn (goto-char (car level-cache))
+ (cdr level-cache)))
+ ;; Buffer modified. Invalidate cache.
+ (unless (eq (buffer-chars-modified-tick) org--up-heading-cache-tick)
+ (setq-local org--up-heading-cache-tick
+ (buffer-chars-modified-tick))
+ (clrhash org--up-heading-cache))
+ (let* ((level-up (1- (funcall outline-level)))
+ (pos (point))
+ (result (and (> level-up 0)
+ (re-search-backward
+ (format "^\\*\\{1,%d\\} " level-up) nil t)
+ (funcall outline-level))))
+ (when result (puthash pos (cons (point) result)
org--up-heading-cache))
+ result))))))
(defun org-up-heading-or-point-min ()
"Move to the heading line of which the present is a subheading, or point-min.
- [elpa] externals/org eeb0450 26/29: Use XDG cache dir as default dir for cache persistance, (continued)
- [elpa] externals/org eeb0450 26/29: Use XDG cache dir as default dir for cache persistance, ELPA Syncer, 2021/10/17
- [elpa] externals/org 8ceb9e7 27/29: Add NEWS entry for new element cache, ELPA Syncer, 2021/10/17
- [elpa] externals/org 85e0a69 20/29: Avoid frequent cache updates in some functions, ELPA Syncer, 2021/10/17
- [elpa] externals/org 7b83168 08/29: org.el/org--property-local-values: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org ec73755 12/29: org.el/org-end-of-subtree: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org fe6cefd 16/29: ox.el: Support cache during export, ELPA Syncer, 2021/10/17
- [elpa] externals/org 60c927f 17/29: Add new element parser and cache tests, ELPA Syncer, 2021/10/17
- [elpa] externals/org 3c4290e 21/29: org.el/org-scan-tags: Make use of fast `org-element-cache-map', ELPA Syncer, 2021/10/17
- [elpa] externals/org 004ac14 28/29: Fix compatibility with Emacs 26, ELPA Syncer, 2021/10/17
- [elpa] externals/org d437817 11/29: org.el/org-goto-first-child: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 399a29c 13/29: org.el/org-up-heading-safe: Add cache support,
ELPA Syncer <=
- [elpa] externals/org 86345df 14/29: org.el/org-in-commented-heading-p: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 5aeeb4f 19/29: Use `org-element-at-point-no-context' in performance-critical places, ELPA Syncer, 2021/10/17
- [elpa] externals/org e70a8aa 18/29: Use org-element-cache in place of text property cache in agenda, ELPA Syncer, 2021/10/17
- [elpa] externals/org 885808f 22/29: Fix incorrectly written test, ELPA Syncer, 2021/10/17
- [elpa] externals/org 85712d6 25/29: Add comments documenting cache diagnostics, ELPA Syncer, 2021/10/17
- [elpa] externals/org abe7222 23/29: Add declares to suppress compiler warnings, ELPA Syncer, 2021/10/17