branch: elpa/annotate
commit 7b1c5aa531d30d60c5c1b5317e374b3eeaf123c3
Merge: f29c91db0b 3413c20594
Author: cage2 <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #168 from cage2/optimize-searching-for-annotations
Optimize searching for annotations
---
Changelog | 28 ++++++++++++++++++++++++----
NEWS.org | 4 ++++
annotate.el | 33 ++++++++++++++++++---------------
3 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/Changelog b/Changelog
index abbe78395e..d7f4f7d05e 100644
--- a/Changelog
+++ b/Changelog
@@ -1,10 +1,30 @@
+2025-03-19 cage
+
+ * annotate.el:
+
+ - optimized 'annotate-annotations-overlay-in-range' by jumping from an
+ annotation to another, instead of scanning every single character of
+ the buffer.
+
+2025-03-06 cage
+
+
+ Merge pull request #166 from
+ cage2/updating-documentation-after-autosave-patch
+
2025-03-05 cage
- * README.org:
+ * Changelog,
+ * NEWS.org,
+ * README.org,
+ * annotate.el:
- Merge pull request #165 from krvkir/master
- - fixed typo in README.
- - updated README.
+ Merge pull request #165 from krvkir/master
+ - fixed typo in README.
+ - updated README.
+ - updated Changelog.
+ - increased version number;
+ - updated NEWS file.
2025-03-02 krvkir
diff --git a/NEWS.org b/NEWS.org
index ec6353513b..95ea04b051 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,7 @@
+- 2025-03-05 v2.3.1 cage ::
+
+ This version optimizes a function that searches for annotations in a buffer;
this changes should speed up commands like
~annotate-toggle-all-annotations-text~.
+
- 2025-03-05 v2.3.0 krvkir ::
This version adds a new customizable variable to instructs annotate.el to
save annotation's database each time a new annotation is created, deleted or
amended.
diff --git a/annotate.el b/annotate.el
index 98597284fe..b666ae1533 100644
--- a/annotate.el
+++ b/annotate.el
@@ -7,7 +7,7 @@
;; Maintainer: Bastian Bechtold <[email protected]>, cage
<[email protected]>
;; URL: https://github.com/bastibe/annotate.el
;; Created: 2015-06-10
-;; Version: 2.3.0
+;; Version: 2.3.1
;; This file is NOT part of GNU Emacs.
@@ -58,7 +58,7 @@
;;;###autoload
(defgroup annotate nil
"Annotate files without changing them."
- :version "2.3.0"
+ :version "2.3.1"
:group 'text)
(defvar annotate-mode-map
@@ -906,7 +906,7 @@ and
(font-lock-flush)))
(defun annotate-toggle-all-annotations-text ()
-"Hide annototation's text in the whole buffer."
+"Hide annotation's text in the whole buffer."
(interactive)
(let ((chains (annotate-annotations-chain-in-range 0 (buffer-size))))
(dolist (chain chains)
@@ -1501,18 +1501,21 @@ surrounded by `BEGIN' and `END'."
(defun annotate-annotations-overlay-in-range (from-position to-position)
"Return the annotations overlays that are enclosed in the range
defined by `FROM-POSITION' and `TO-POSITION'."
- (let ((annotations ()))
- (cl-loop for i
- from (max 0 (1- from-position))
- to to-position
- do
- (let ((annotation (annotate-next-annotation-starts i)))
- (annotate-ensure-annotation (annotation)
- (let ((chain-end (overlay-end (annotate-chain-last annotation)))
- (chain-start (overlay-start (annotate-chain-first
annotation))))
- (when (and (>= chain-start from-position)
- (<= chain-end to-position))
- (cl-pushnew annotation annotations))))))
+ (let ((annotations ())
+ (counter (max 0 (1- from-position))))
+ (catch 'scan-loop
+ (while (<= counter
+ to-position)
+ (cl-incf counter)
+ (let ((annotation (annotate-next-annotation-starts counter)))
+ (if (annotationp annotation)
+ (let ((chain-end (overlay-end (annotate-chain-last
annotation)))
+ (chain-start (overlay-start (annotate-chain-first
annotation))))
+ (setf counter chain-end)
+ (when (and (>= chain-start from-position)
+ (<= chain-end to-position))
+ (cl-pushnew annotation annotations)))
+ (throw 'scan-loop t)))))
(reverse annotations)))
(defun annotate-annotations-chain-in-range (from-position to-position)