[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 3f0c28cab6 241/372: - fixed a bug that allowed to
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 3f0c28cab6 241/372: - fixed a bug that allowed to create an annotation with an empty text. |
Date: |
Fri, 4 Feb 2022 16:59:03 -0500 (EST) |
branch: elpa/annotate
commit 3f0c28cab626b234130f060bb78abc7a28b200b9
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- fixed a bug that allowed to create an annotation with an empty text.
annotate-create-annotation now signals a condition (error) if
an user is asked to create an annotation with no annotation text.
---
annotate.el | 72 +++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 41 insertions(+), 31 deletions(-)
diff --git a/annotate.el b/annotate.el
index 3677e2ab3e..899628a9d8 100644
--- a/annotate.el
+++ b/annotate.el
@@ -247,6 +247,10 @@ annotation as defined in the database."
(defconst annotate-summary-replace-button-label "[replace]"
"The label for the button, in summary window, to replace an annotation")
+(define-error 'annotate-error "Annotation error")
+
+(define-error 'annotate-empty-annotation-text-error "Empty annotation text"
'annotate-error)
+
(defun annotate-annotations-exist-p ()
"Does this buffer contains at least one or more annotations?"
(cl-find-if 'annotationp
@@ -395,7 +399,10 @@ modified (for example a newline is inserted)."
(cl-destructuring-bind (start end)
(annotate-bounds)
(let ((annotation-text (read-from-minibuffer
annotate-annotation-prompt)))
- (annotate-create-annotation start end annotation-text
nil)))))
+ (condition-case error-message
+ (annotate-create-annotation start end annotation-text
nil)
+ (annotate-empty-annotation-text-error
+ (user-error "Annotation text is empty.")))))))
(let ((annotation (annotate-annotation-at (point))))
(cond
((use-region-p)
@@ -1567,36 +1574,39 @@ The searched interval can be customized setting the
variable:
(when force-newline-p
(annotate-annotation-force-newline-policy annotation))
annotation))))
- (if (not (annotate-string-empty-p annotated-text))
- (let ((text-to-match (ignore-errors
- (buffer-substring-no-properties start end))))
- (if (and text-to-match
- (string= text-to-match annotated-text))
- (create-annotation start end annotation-text)
- (let* ((starting-point-matching (go-backward start))
- (ending-point-match (go-forward start))
- (length-match (- end start))
- (new-match (guess-match-and-add
starting-point-matching
- (+
starting-point-matching
-
length-match)
-
annotated-text
-
ending-point-match)))
- (and new-match
- (create-annotation new-match
- (+ new-match length-match)
- annotation-text)))
- (lwarn '(annotate-mode) ; if matches annotated text failed
- :warning
-
annotate-warn-file-searching-annotation-failed-control-string
- (annotate-actual-file-name)
- annotation-text
- text-to-match)))
- (create-annotation start end annotation-text)) ; create new annotation
- (when (use-region-p)
- (deactivate-mark))
- (save-excursion
- (goto-char end)
- (font-lock-fontify-block 1))))
+ (if (annotate-string-empty-p annotation-text)
+ (signal 'annotate-empty-annotation-text-error t)
+ (progn
+ (if (not (annotate-string-empty-p annotated-text))
+ (let ((text-to-match (ignore-errors
+ (buffer-substring-no-properties start
end))))
+ (if (and text-to-match
+ (string= text-to-match annotated-text))
+ (create-annotation start end annotation-text)
+ (let* ((starting-point-matching (go-backward start))
+ (ending-point-match (go-forward start))
+ (length-match (- end start))
+ (new-match (guess-match-and-add
starting-point-matching
+ (+
starting-point-matching
+
length-match)
+
annotated-text
+
ending-point-match)))
+ (and new-match
+ (create-annotation new-match
+ (+ new-match length-match)
+ annotation-text)))
+ (lwarn '(annotate-mode) ; if matches annotated text failed
+ :warning
+
annotate-warn-file-searching-annotation-failed-control-string
+ (annotate-actual-file-name)
+ annotation-text
+ text-to-match)))
+ (create-annotation start end annotation-text)) ; create new
annotation
+ (when (use-region-p)
+ (deactivate-mark))
+ (save-excursion
+ (goto-char end)
+ (font-lock-fontify-block 1))))))
(defun annotate-change-annotation (pos)
"Change annotation at point. If empty, delete annotation."
- [nongnu] elpa/annotate fccf7a5b51 178/372: Merge branch 'master' into org-mode-fix, (continued)
- [nongnu] elpa/annotate fccf7a5b51 178/372: Merge branch 'master' into org-mode-fix, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ca86e4a511 187/372: - removed org-mode from blacklist., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 822ed91a87 206/372: - fixed exporting and integrations of annotations;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 5e2609e16e 207/372: - optimized 'annotate-previous-annotation-ends' and 'annotate-next-annotation-starts'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 085791450c 215/372: - changed version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c72e730ba3 217/372: - fixed annotation picking in 'annotate-annotate', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a38a2ff6b4 221/372: - updated version and documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bb8cda2edc 238/372: - actually changed version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e2fed2fbcf 246/372: - removed useless spaces., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 85520c0202 228/372: - fixed version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3f0c28cab6 241/372: - fixed a bug that allowed to create an annotation with an empty text.,
ELPA Syncer <=
- [nongnu] elpa/annotate 2050c59af3 227/372: - marked buffer as unmodified when switching database and the only, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 99d99e5bcb 234/372: Merge pull request #72 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4b2fa8f61e 252/372: - removed function 'annotate-load-annotation-data-ignore-errors'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c972641056 258/372: - Using "help-echo" to print annotations instead of render it on the buffer., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9320918b91 270/372: Merge pull request #84 from cage2/fix-regression-multiline-annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e70e187b3 262/372: - updated NEWS and Changelog., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4af196ce04 312/372: - updated Changelog and NEWS.org., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3a4dc507c2 305/372: - removed unused functions., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3458b548f4 303/372: - removed warning related to misplaced '(interactive)', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed5f00d51c 351/372: - increased version number., ELPA Syncer, 2022/02/04