[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate d4b555d237 242/372: Merge pull request #76 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate d4b555d237 242/372: Merge pull request #76 from cage2/master |
Date: |
Fri, 4 Feb 2022 16:59:04 -0500 (EST) |
branch: elpa/annotate
commit d4b555d2374f60edd56d196df535523da422a005
Merge: a04a6144aa 3f0c28cab6
Author: cage2 <1257703+cage2@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #76 from cage2/master
Fixed a bug that allowed to create an annotation with an empty 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 4bcecdc875 156/372: - replaced 'splitted-annotation' with 'multiline-annotation'., (continued)
- [nongnu] elpa/annotate 4bcecdc875 156/372: - replaced 'splitted-annotation' with 'multiline-annotation'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4fde80fe79 168/372: - updated software version number in the comment on top of the source code;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 696f4ee0cd 167/372: Merge pull request #55 from cage2/update-doc, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a59cc2c6b2 172/372: - when 'delete' button from a summary window is activated redraw and, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 412053cefc 173/372: - [bugfix] When a window is resized ensure that the sizes are, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 41e85c8435 176/372: - increased version number;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate cc4292cce4 181/372: - moved the test for 'limit' up in the lambda of the filtering, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f4cc83ec84 189/372: Merge branch 'master' into org-mode-fix, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bcffdb9f24 202/372: - added some missing docstrings., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 99c45f553e 225/372: Merge pull request #67 from cage2/new-stable-version, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d4b555d237 242/372: Merge pull request #76 from cage2/master,
ELPA Syncer <=
- [nongnu] elpa/annotate a04a6144aa 240/372: Merge pull request #75 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a4607c4184 273/372: - updated version and documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate daf4c3c726 283/372: - removed code, in integration procedures, that should never runs., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3239275a5b 265/372: - fitted 'annotate-position-inside-chain-p' into, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b68170837e 279/372: - fixed the width of the last row of the box, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 958ce126e0 272/372: - fixed more typos., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d55c48f508 304/372: changed function from 'font-lock-fontify-buffer' to 'font-lock-ensure'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 876f1425d2 310/372: - removed another useless argument from call to 'font-lock-flush'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate cc9393c6bd 318/372: - when annotationg a newline, replace annotation if a single one, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 92434b63ff 323/372: - improved documentation and fixed indentation for a couple of local functions., ELPA Syncer, 2022/02/04