mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-29 07:58:21 +00:00
org-element: Allow force-quitting during cache sync
* lisp/org-element.el (org-element--cache-interrupt-C-g, org-element--cache-interrupt-C-g-max-count, org-element--cache-interrupt-C-g-count): New variables controlling force-quitting cache sync process. If `org-element--cache-interrupt-C-g' is non-nil, user can force terminating syncronisation request even in the middle of sync process by invoking `keyboard-quit' `org-element--cache-interrupt-C-g-max-count' times. `org-element--cache-interrupt-C-g-count' stores the number of invokations during current sync process. (org-element--cache-sync): Initialise `org-element--cache-interrupt-C-g-count' before processing sync request. (org-element--parse-to): Handle interruption in potentially infinite loop.
This commit is contained in:
parent
a149fdd569
commit
4eab5bd3f0
@ -5772,6 +5772,10 @@ Properties are modified by side-effect."
|
||||
(plist-get properties key))))
|
||||
(and value (plist-put properties key (+ offset value)))))))
|
||||
|
||||
(defvar org-element--cache-interrupt-C-g nil)
|
||||
(defvar org-element--cache-interrupt-C-g-max-count 5)
|
||||
(defvar org-element--cache-interrupt-C-g-count 0)
|
||||
|
||||
(defun org-element--cache-sync (buffer &optional threshold future-change)
|
||||
"Synchronize cache with recent modification in BUFFER.
|
||||
|
||||
@ -5797,6 +5801,7 @@ updated before current modification are actually submitted."
|
||||
this-command)
|
||||
(org-element-cache-reset))
|
||||
(let ((inhibit-quit t) request next)
|
||||
(setq org-element--cache-interrupt-C-g-count 0)
|
||||
(when org-element--cache-sync-timer
|
||||
(cancel-timer org-element--cache-sync-timer))
|
||||
(let ((time-limit (time-add nil org-element-cache-sync-duration)))
|
||||
@ -6262,8 +6267,17 @@ the process stopped before finding the expected result."
|
||||
(while t
|
||||
(when (org-element--cache-interrupt-p time-limit)
|
||||
(throw 'interrupt nil))
|
||||
(when (and inhibit-quit org-element--cache-interrupt-C-g)
|
||||
(when quit-flag
|
||||
(cl-incf org-element--cache-interrupt-C-g-count)
|
||||
(setq quit-flag nil))
|
||||
(when (> org-element--cache-interrupt-C-g-count
|
||||
org-element--cache-interrupt-C-g-max-count)
|
||||
(setq quit-flag t)
|
||||
(org-element-cache-reset)
|
||||
(error "org-element: Parsing aborted by user. Cache has been cleared.")))
|
||||
(unless element
|
||||
;; Do not try to parse withi blank at EOB.
|
||||
;; Do not try to parse within blank at EOB.
|
||||
(unless (save-excursion
|
||||
(org-skip-whitespace)
|
||||
(eobp))
|
||||
|
Loading…
Reference in New Issue
Block a user