[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 04a5710cf6 334/372: - prevented saving a file whi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 04a5710cf6 334/372: - prevented saving a file whith an empty database; |
Date: |
Fri, 4 Feb 2022 16:59:18 -0500 (EST) |
branch: elpa/annotate
commit 04a5710cf6b0c738564fa343089d8d88f8c7ae2d
Author: cage <cage@invalid>
Commit: cage <cage@invalid>
- prevented saving a file whith an empty database;
---
annotate.el | 44 ++++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 12 deletions(-)
diff --git a/annotate.el b/annotate.el
index 6ff3fc2ad1..6b1a2a1d64 100644
--- a/annotate.el
+++ b/annotate.el
@@ -155,6 +155,13 @@ database is not filtered at all."
:type 'boolean
:group 'annotate)
+(defcustom annotate-database-confirm-deletion t
+ "If non nil a prompt asking confirmation before deleting a
+database file that is going to be empty after saving an annotated
+file will be shown"
+ :type 'boolean
+ :group 'annotate)
+
(defcustom annotate-annotation-max-size-not-place-new-line 15
"The maximum `string-width` allowed for an annotation to be
placed on the right margin of the window instead of its own line
@@ -1565,19 +1572,32 @@ annotation."
(ignore-errors (%load-annotation-data))
(%load-annotation-data))))
-(defun annotate-dump-annotation-data (data)
+(defun annotate-dump-annotation-data (data &optional save-empty-db)
"Save `data` into annotation file."
- (with-temp-file annotate-file
- (let* ((print-length nil)
- (%abbreviate-filename (lambda (record)
- (let ((full-filename
(annotate-filename-from-dump record))
- (annotations
(annotate-annotations-from-dump record))
- (file-checksum
(annotate-checksum-from-dump record)))
- (annotate-make-record
(abbreviate-file-name full-filename)
- annotations
- file-checksum))))
- (actual-data (mapcar %abbreviate-filename data)))
- (prin1 actual-data (current-buffer)))))
+ (if (or save-empty-db
+ data)
+ (with-temp-file annotate-file
+ (let* ((print-length nil)
+ (%abbreviate-filename (lambda (record)
+ (let ((full-filename
(annotate-filename-from-dump record))
+ (annotations
(annotate-annotations-from-dump record))
+ (file-checksum
(annotate-checksum-from-dump record)))
+ (annotate-make-record
(abbreviate-file-name full-filename)
+ annotations
+
file-checksum))))
+ (actual-data (mapcar %abbreviate-filename data)))
+ (prin1 actual-data (current-buffer))))
+ (let* ((confirm-message "Delete annotations database file %S? [y/N] ")
+ (delete-confirmed-p (or (not annotate-database-confirm-deletion)
+ (string= (read-from-minibuffer (format
confirm-message
+
annotate-file))
+ "y"))))
+ (if delete-confirmed-p
+ (condition-case err
+ (delete-file annotate-file t)
+ (error (message "error removing annotation database: %S"
+ (error-message-string err))))
+ (annotate-dump-annotation-data data t)))))
(cl-defmacro with-matching-annotation-fns ((filename
beginning
- [nongnu] elpa/annotate cc9393c6bd 318/372: - when annotationg a newline, replace annotation if a single one, (continued)
- [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
- [nongnu] elpa/annotate a45584c53f 358/372: - removed customizable function 'annotate-y-or-n-prompt-function'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 07667d4ccb 314/372: - updated version number in top comment block., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 641daae9d0 335/372: - updated docs and version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b74bade94c 345/372: - increased version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e6af7f8ef7 058/372: workaround for nil file name, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate eb01c0cfbb 077/372: - removed copyright line from README., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d2841bad65 325/372: - ensured all annotations are saved before showing summary window., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6239d033ce 355/372: - updated README.org mentioning 'annotate-y-or-n-prompt-function'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 04a5710cf6 334/372: - prevented saving a file whith an empty database;,
ELPA Syncer <=
- [nongnu] elpa/annotate 2e7c18b12a 337/372: - fixed callback for "[replace]" button in summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6b73ccf009 352/372: - fixed function's name., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4c3ba3a5da 331/372: - prevented calling 'annotate--remove-annotation-property' on a narrowed buffer, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3b0bc40a4f 347/372: - improved docstrings;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 46aa377cfc 370/372: - upgraded version number;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0cfad246ee 372/372: Merge pull request #120 from cage2/add-merge-db, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 401a9b4990 309/372: - removed useless argument for 'font-lock-flush'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ed0c9bc64b 184/372: - prevented annotation of text marked with a region that overlap with, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 24de0e4607 190/372: - renamed and fixed function to search for annotations relative to a, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e6fb2b31df 188/372: - fixed position to start for overlay checks in, ELPA Syncer, 2022/02/04