[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 774e643af4 081/372: - fixed retrocompatibility wi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 774e643af4 081/372: - fixed retrocompatibility with old annotation file format. |
Date: |
Fri, 4 Feb 2022 16:58:20 -0500 (EST) |
branch: elpa/annotate
commit 774e643af44e0a052228b4de31cd370c25285061
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- fixed retrocompatibility with old annotation file format.
---
annotate.el | 102 ++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 71 insertions(+), 31 deletions(-)
diff --git a/annotate.el b/annotate.el
index 5022cadcb5..d2df7aadd4 100644
--- a/annotate.el
+++ b/annotate.el
@@ -123,7 +123,7 @@ less than this size (in characters)"
(defconst annotate-warn-file-changed-control-string
(concat "The file '%s' has changed on disk "
- "from the last time the annotations was saved. "
+ "from the last time the annotations was saved.\n"
"Chances are that they will not be displayed correctly")
"The message to warn user that file has been modified and
annototatnions position could be outdated")
@@ -152,29 +152,41 @@ major mode is a member of this list (space separated
entries)."
(md5 object)
nil))
+(cl-defmacro annotate-with-inhibit-modification-hooks (&rest body)
+ `(unwind-protect
+ (progn
+ (setf inhibit-modification-hooks t)
+ ,@body)
+ (setf inhibit-modification-hooks t)))
+
(defun annotate-initialize ()
"Load annotations and set up save and display hooks."
(annotate-load-annotations)
(add-hook 'after-save-hook 'annotate-save-annotations t t)
- (add-hook 'window-configuration-change-hook 'font-lock-fontify-buffer t t)
+ (add-hook 'window-configuration-change-hook 'font-lock-fontify-buffer t t)
(font-lock-add-keywords
- nil '((annotate--font-lock-matcher (2 (annotate--annotation-builder))
- (1 (annotate--change-guard))))))
+ nil
+ '((annotate--font-lock-matcher (2 (annotate--annotation-builder))
+ (1 (annotate--change-guard))))))
(defun annotate-shutdown ()
"Clear annotations and remove save and display hooks."
(annotate-clear-annotations)
- (remove-hook 'after-save-hook 'annotate-save-annotations t)
- (remove-hook 'window-configuration-change-hook 'font-lock-fontify-buffer t)
+ (remove-hook 'after-save-hook 'annotate-save-annotations t)
+ (remove-hook 'window-configuration-change-hook 'font-lock-fontify-buffer t)
(font-lock-remove-keywords
- nil '((annotate--font-lock-matcher (2 (annotate--annotation-builder))
- (1 (annotate--change-guard))))))
+ nil
+ '((annotate--font-lock-matcher (2 (annotate--annotation-builder))
+ (1 (annotate--change-guard))))))
(defun annotate-overlay-filled-p (overlay)
(and overlay
(overlayp overlay)
(overlay-get overlay 'annotation)))
+(defun annotationp (overlay)
+ (annotate-overlay-filled-p overlay))
+
(defun annotate-annotate ()
"Create, modify, or delete annotation."
(interactive)
@@ -247,10 +259,9 @@ major mode is a member of this list (space separated
entries)."
(dolist (entry all-annotations)
(delete-dups entry))
;; skip files with no annotations
- (annotate-dump-annotation-data (cl-remove-if
- (lambda (entry)
- (eq nil (cdr entry)))
- all-annotations))
+ (annotate-dump-annotation-data (cl-remove-if (lambda (entry)
+ (eq nil (cdr entry)))
+ all-annotations))
(if annotate-use-messages
(message "Annotations saved."))))
@@ -676,8 +687,10 @@ to 'maximum-width'."
that strips dangling `display` properties of text insertions if
text is inserted. This cleans up after newline insertions between
an overlay and it's annotation."
- (list 'face nil
- 'insert-in-front-hooks '(annotate--remove-annotation-property)))
+ (list 'face
+ nil
+ 'insert-in-front-hooks
+ '(annotate--remove-annotation-property)))
(defun annotate-context-before (pos)
"Context lines before POS."
@@ -716,25 +729,15 @@ an overlay and it's annotation."
(defun annotate-annotations-from-dump (record)
(nth 1 record))
-(defun annotate-load-annotations ()
- "Load all annotations from disk."
+(defun annotate-load-annotation-old-format ()
+ "Load all annotations from disk in old format."
(interactive)
- (let* ((filename (substring-no-properties (or (buffer-file-name)
"")))
- (all-annotations-data (annotate-load-annotation-data))
- (annotation-dump (assoc-string filename all-annotations-data))
- (annotations (annotate-annotations-from-dump
annotation-dump))
- (old-checksum (annotate-checksum-from-dump annotation-dump))
- (new-checksum (annotate-buffer-checksum))
- (modified-p (buffer-modified-p)))
- (when (and old-checksum
- new-checksum
- (not (string= old-checksum new-checksum)))
- (lwarn "annotate-mode"
- :warning
- annotate-warn-file-changed-control-string
- filename))
+ (let ((annotations (cdr (assoc-string
+ (substring-no-properties (or (buffer-file-name) ""))
+ (annotate-load-annotation-data))))
+ (modified-p (buffer-modified-p)))
;; remove empty annotations created by earlier bug:
- (setq annotations (cl-remove-if (lambda (ann) (null (nth 2 ann)))
+ (setq annotations (cl-remove-if (lambda (ann) (eq (nth 2 ann) nil))
annotations))
(when (and (eq nil annotations) annotate-use-messages)
(message "No annotations found."))
@@ -750,6 +753,43 @@ an overlay and it's annotation."
(if annotate-use-messages
(message "Annotations loaded."))))
+(defun annotate-load-annotations ()
+ "Load all annotations from disk."
+ (cl-labels ((old-format-p (annotation)
+ (not (stringp (cl-first (last annotation))))))
+ (interactive)
+ (let* ((filename (substring-no-properties (or
(buffer-file-name) "")))
+ (all-annotations-data (annotate-load-annotation-data))
+ (annotation-dump (assoc-string filename all-annotations-data))
+ (annotations (annotate-annotations-from-dump
annotation-dump))
+ (old-checksum (annotate-checksum-from-dump annotation-dump))
+ (new-checksum (annotate-buffer-checksum))
+ (modified-p (buffer-modified-p)))
+ (if (old-format-p annotation-dump)
+ (annotate-load-annotation-old-format)
+ (when (and (not (old-format-p annotations))
+ old-checksum
+ new-checksum
+ (not (string= old-checksum new-checksum)))
+ (lwarn "annotate-mode"
+ :warning
+ annotate-warn-file-changed-control-string
+ filename))
+ (when (and (eq nil annotations)
+ annotate-use-messages)
+ (message "No annotations found."))
+ (when (not (eq nil annotations))
+ (save-excursion
+ (dolist (annotation annotations)
+ (let ((start (nth 0 annotation))
+ (end (nth 1 annotation))
+ (text (nth 2 annotation)))
+ (annotate-create-annotation start end text)))))
+ (set-buffer-modified-p modified-p)
+ (font-lock-fontify-buffer)
+ (when annotate-use-messages
+ (message "Annotations loaded."))))))
+
(defun annotate-clear-annotations ()
"Clear all current annotations."
(interactive)
- [nongnu] elpa/annotate 2084f831bc 026/372: added export functionality as sort-of-diffscuss, (continued)
- [nongnu] elpa/annotate 2084f831bc 026/372: added export functionality as sort-of-diffscuss, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 52f0d97e51 030/372: new version and documentation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b0266c6350 047/372: version 0.4.1, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4647264264 049/372: auto-reflow annotations when frame size changes, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 785b5aea7f 042/372: rework annotation display logic, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d6a4fcc18e 035/372: add next-annotation and previous-annotation keys, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f5711b4f27 067/372: - prevent crash and error when a frame's width is less than value of, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1a43bfbb1e 061/372: fixes bug with annotations ending on beginning-of-line, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9ffdc1f762 060/372: fix for annotations with wide characters, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 19acc501d8 086/372: - added/fixed more docstrings., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 774e643af4 081/372: - fixed retrocompatibility with old annotation file format.,
ELPA Syncer <=
- [nongnu] elpa/annotate 4d78e3f6d6 073/372: - restored spaces to comply with markdown syntax;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 95da172588 056/372: readme improvement, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 54aefdec8d 114/372: Merge pull request #46 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 201b4587dc 136/372: - made recongnizable code that refers to info file annotation (1/3), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate fd2cd2d94d 139/372: - made text snippet in summary window, for info files, less messy., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 75d291a69f 141/372: - using 'annotate-with-inhibit-modification-hooks'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 5b69043454 152/372: - added variable 'annotate-annotation-position-policy', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 5b0bb094c9 166/372: - added known bug;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4972c555c6 171/372: - fixed version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 004aea92ea 179/372: - updated documentation;, ELPA Syncer, 2022/02/04