emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/annotate d7246d5220 006/372: implemented annotation saving


From: ELPA Syncer
Subject: [nongnu] elpa/annotate d7246d5220 006/372: implemented annotation saving
Date: Fri, 4 Feb 2022 16:58:14 -0500 (EST)

branch: elpa/annotate
commit d7246d5220b99499466e3b1f3068f631bbec724c
Author: Bastian Bechtold <basti@bastibe.de>
Commit: Bastian Bechtold <basti@bastibe.de>

    implemented annotation saving
---
 annotate.el | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/annotate.el b/annotate.el
index 34b269a3dc..23669b3f1b 100644
--- a/annotate.el
+++ b/annotate.el
@@ -83,3 +83,25 @@
          ((region-active-p) (region-end))
          ((thing-at-point 'symbol) (cdr (bounds-of-thing-at-point 'symbol)))
          (t (1+ (point))))))
+
+(defun annotate-save-annotations ()
+  "Save all annotations to disk."
+  (interactive)
+  (let ((annotations
+         (mapcar 'annotate-describe-annotation (overlays-in 0 (buffer-size)))))
+    (append-to-file (concat (format "\n:%s\n" (buffer-file-name))
+                            (apply 'concat annotations))
+                    nil annotate-file)))
+
+(defun annotate-describe-annotation (highlight)
+  (save-excursion
+    (goto-char (overlay-start highlight))
+    (format "%s (line %s, %s-%s): %s\n"
+            (prin1-to-string (buffer-substring-no-properties
+                              (overlay-start highlight)
+                              (overlay-end highlight)))
+            (line-number-at-pos)
+            (current-column)
+            (+ (current-column) (- (overlay-end highlight)
+                                   (overlay-start highlight)))
+            (prin1-to-string (overlay-get highlight 'annotation)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]