[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 9cc55145de 150/372: - shown, when editing annotat
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 9cc55145de 150/372: - shown, when editing annotation in summary window and asking user to |
Date: |
Fri, 4 Feb 2022 16:58:39 -0500 (EST) |
branch: elpa/annotate
commit 9cc55145de7d741af08fe66dad6bc01b989ee90c
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- shown, when editing annotation in summary window and asking user to
type the new annotation text, the old annotation in the minibuffer
(so the user can use the old one as basis for the new annotation);
- refactoring out some local functions related to searching annotation
database.
---
annotate.el | 121 ++++++++++++++++++++++++++++++++----------------------------
1 file changed, 65 insertions(+), 56 deletions(-)
diff --git a/annotate.el b/annotate.el
index 969999fcea..7060c41777 100644
--- a/annotate.el
+++ b/annotate.el
@@ -1129,6 +1129,21 @@ annotation."
(let ((print-length nil))
(prin1 data (current-buffer)))))
+(cl-defmacro with-matching-annotation-fns ((filename
+ beginning
+ ending)
+ &body body)
+ "Anaphoric macro to build functions to find annotations"
+ `(let ((filename-match-p (lambda (record)
+ (string= (annotate-filename-from-dump
record)
+ ,filename)))
+ (annotation-limits-match-p (lambda (a)
+ (and (=
(annotate-beginning-of-annotation a)
+ ,beginning)
+ (= (annotate-ending-of-annotation
a)
+ ,ending)))))
+ ,@body))
+
(defun annotate-db-remove-annotation (db-records
record-filename
annotation-beginning
@@ -1136,67 +1151,59 @@ annotation."
"Remove from database `db-records' the annotation indentified by
the triplets `record-filename', `annotation-beginning' and
`annotation-ending'; if such annotation does exists."
- (let* ((filename-match-p (lambda (record)
- (string= (annotate-filename-from-dump record)
- record-filename)))
- (file-matched-record (cl-find-if filename-match-p db-records)))
- (if file-matched-record
- (let* ((rest-of-db (cl-remove-if filename-match-p db-records))
- (new-annotations (cl-remove-if (lambda (a)
- (and (=
(annotate-beginning-of-annotation a)
- annotation-beginning)
- (=
(annotate-ending-of-annotation a)
- annotation-ending)))
- (annotate-annotations-from-dump
file-matched-record)))
- (checksum (annotate-checksum-from-dump
file-matched-record))
- (new-record (annotate-make-record record-filename
- new-annotations
- checksum)))
- (push new-record
- rest-of-db))
- db-records)))
+ (with-matching-annotation-fns
+ (record-filename
+ annotation-beginning
+ annotation-ending)
+ (let ((file-matched-record (cl-find-if filename-match-p db-records)))
+ (if file-matched-record
+ (let* ((rest-of-db (cl-remove-if filename-match-p db-records))
+ (new-annotations (cl-remove-if annotation-limits-match-p
+ (annotate-annotations-from-dump
file-matched-record)))
+ (checksum (annotate-checksum-from-dump
file-matched-record))
+ (new-record (annotate-make-record record-filename
+ new-annotations
+ checksum)))
+ (push new-record
+ rest-of-db))
+ db-records))))
(defun annotate-db-replace-annotation (db-records
record-filename
annotation-beginning
annotation-ending
replacing-text)
- "TODO"
- (let* ((filename-match-p (lambda (record)
- (string= (annotate-filename-from-dump record)
- record-filename)))
- (file-matched-record (cl-find-if filename-match-p db-records)))
- (if file-matched-record
- (let ((old-annotation (cl-find-if (lambda (a)
- (and (=
(annotate-beginning-of-annotation a)
- annotation-beginning)
- (=
(annotate-ending-of-annotation a)
- annotation-ending)))
- (annotate-annotations-from-dump
file-matched-record))))
- (if old-annotation
- (let* ((rest-of-db (cl-remove-if filename-match-p
db-records))
- (rest-annotations (cl-remove-if (lambda (a)
- (and (=
(annotate-beginning-of-annotation a)
-
annotation-beginning)
- (=
(annotate-ending-of-annotation a)
-
annotation-ending)))
-
(annotate-annotations-from-dump file-matched-record)))
- (checksum (annotate-checksum-from-dump
file-matched-record))
- (new-annotation (annotate-make-annotation
annotation-beginning
-
annotation-ending
-
replacing-text
-
(annotate-annotated-text old-annotation)))
- (new-record (annotate-make-record record-filename
- (append (list
new-annotation)
-
rest-annotations)
- checksum)))
- (push new-record
- rest-annotations)
- (push new-record
- rest-of-db))
- db-records))
- db-records)))
-
+ "Replace the text of annotation from database `db-records'
+ indentified by the triplets `record-filename',
+ `annotation-beginning' and `annotation-ending'; if such
+ annotation does exists."
+ (with-matching-annotation-fns
+ (record-filename
+ annotation-beginning
+ annotation-ending)
+ (let ((file-matched-record (cl-find-if filename-match-p db-records)))
+ (if file-matched-record
+ (let ((old-annotation (cl-find-if annotation-limits-match-p
+ (annotate-annotations-from-dump
file-matched-record))))
+ (if old-annotation
+ (let* ((rest-of-db (cl-remove-if filename-match-p
db-records))
+ (rest-annotations (cl-remove-if annotation-limits-match-p
+
(annotate-annotations-from-dump file-matched-record)))
+ (checksum (annotate-checksum-from-dump
file-matched-record))
+ (new-annotation (annotate-make-annotation
annotation-beginning
+
annotation-ending
+
replacing-text
+
(annotate-annotated-text old-annotation)))
+ (new-record (annotate-make-record record-filename
+ (append (list
new-annotation)
+
rest-annotations)
+ checksum)))
+ (push new-record
+ rest-annotations)
+ (push new-record
+ rest-of-db))
+ db-records))
+ db-records))))
;;;; database related procedures ends here
@@ -1467,7 +1474,8 @@ sophisticated way than plain text"
(annotation-ending (button-get button 'ending))
(query (button-get button 'query))
(db (annotate-load-annotation-data))
- (new-annotation-text (read-from-minibuffer
annotate-annotation-prompt)))
+ (old-annotation (button-get button 'text))
+ (new-annotation-text (read-from-minibuffer
annotate-annotation-prompt old-annotation)))
(when (not (annotate-string-empty-p new-annotation-text))
(let ((replaced-annotation-db (annotate-db-replace-annotation db
filename
@@ -1542,6 +1550,7 @@ results can be filtered with a simple query language: see
'beginning
annotation-beginning
'ending annotation-ending
'query filter-query
+ 'text button-text
'action
'annotate-summary-replace-annotation-button-pressed
'type
- [nongnu] elpa/annotate 7ff18171a6 112/372: - fixed typos., (continued)
- [nongnu] elpa/annotate 7ff18171a6 112/372: - fixed typos., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7ebddc73a0 144/372: - enabled filtering of annotation database when a summary window is shown., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50ba1d719c 143/372: - used a better regex when checking if a file is in info format., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 50bc634f6b 140/372: - placed the cursor in the right place (on the annotated text) when an, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1f9899071f 138/372: - made recongnizable code that refers to info file annotation. (3/3), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4629a0ad34 148/372: Merge pull request #51 from cage2/filter-summary-window-results, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4372e9ea20 147/372: - changed escaping mechanism;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6948bfe686 146/372: - minor fix in comments., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b116d3125a 149/372: - added the chance to delete annotation and modify the annotated text, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e76557cf7 154/372: Merge pull request #53 from cage2/summary-win-delete-replace-annotation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9cc55145de 150/372: - shown, when editing annotation in summary window and asking user to,
ELPA Syncer <=
- [nongnu] elpa/annotate a370187f0b 151/372: - initial working on placing an annotation on its own line if too long., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2292d5c6c8 160/372: - changed variable name from: 'text' to a more meaningful 'annotated text'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 54d112e8d3 174/372: [bugfix] mitigated bug that prevented rendering of annotation when, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 91412e5d65 175/372: - removed multiple, consecutive, spaces in comments., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed6a7dd7cc 180/372: - prevented fails of fontification of annotated regions, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e4a7750e8c 183/372: - prevented overlapping of annotations when a symbol is already, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate eaffc1eba1 185/372: - mark buffer as modified even if the only action the user performed, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7cf7f46be0 191/372: - removed duplicated function., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9c2bf1bd36 192/372: - used the correct functions when recurse., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 78fc74289f 194/372: - use iteration instead of recursion in, ELPA Syncer, 2022/02/04