[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate cc0b5da6c1 229/372: Merge pull request #69 from c
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate cc0b5da6c1 229/372: Merge pull request #69 from cage2/switch-database |
Date: |
Fri, 4 Feb 2022 16:59:02 -0500 (EST) |
branch: elpa/annotate
commit cc0b5da6c1f8f09cc3ebe1c0d130c093c7e1d3c6
Merge: 99c45f553e 85520c0202
Author: cage2 <1257703+cage2@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #69 from cage2/switch-database
- added a couple of functions to allow an user to change annotation database
---
Changelog | 7 ++++++-
NEWS.org | 3 +++
README.org | 12 ++++++++++--
annotate.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/Changelog b/Changelog
index 5b572e1e82..1fb758125c 100644
--- a/Changelog
+++ b/Changelog
@@ -1,10 +1,15 @@
+2020-06-09 Bastian Bechtold, cage
+ * annotate.el (annotate-buffers-annotate-mode, annotate-switch-db)
+ - added functions to switch the database of annotations used for the
emacs session;
+ - increased version to 0.8.0
+
2020-05-18 Bastian Bechtold, cage
* annotate.el
- Increased version to 0.7.0 for stable release
2020-01-25 Bastian Bechtold, cage
- * annotate.el (defun annotate-annotation-force-newline-policy,
+ * annotate.el (annotate-annotation-force-newline-policy,
annotate-annotation-newline-policy-forced-p,
annotate-create-annotation,
annotate-lineate,
diff --git a/NEWS.org b/NEWS.org
index 9c9f82552a..cbbce9065c 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -114,3 +114,6 @@
- 2020-05-18 V0.7.0 Bastian Bechtold, cage ::
Increased version to 0.7.0 for stable release
+
+- 2020-06-09 V0.8.0 Bastian Bechtold, cage ::
+ The database of annotation can be changed using the command
~annotate-switch-db~.
diff --git a/README.org b/README.org
index a978e841f7..19c655be97 100644
--- a/README.org
+++ b/README.org
@@ -30,8 +30,16 @@ previous annotation.
** Metadata
-All annotations are saved in ~annotate-file~ (=~/.annotations= by
-default).
+The current database for annotations is contained in the file
+indicated by the variable ~annotate-file~ (=~/.emacs.d/annotations= by
+default) but each user can change this value in a dynamic way using
+the command ~annotate-switch-db~. This command will take care to
+refresh/redraw all annotations in the buffers that uses
+~annotate-mode~.
+
+Please note that switching database, in this context, means rebinding
+the aforementioned variable (~annotate-file~). This means than no
+more than a single database can be active for each Emacs session.
Users of
[[https://github.com/emacscollective/no-littering][no-littering]]
diff --git a/annotate.el b/annotate.el
index e138fa924e..84789fcc5d 100644
--- a/annotate.el
+++ b/annotate.el
@@ -7,7 +7,7 @@
;; Maintainer: Bastian Bechtold
;; URL: https://github.com/bastibe/annotate.el
;; Created: 2015-06-10
-;; Version: 0.7.0
+;; Version: 0.8.0
;; This file is NOT part of GNU Emacs.
@@ -55,7 +55,7 @@
;;;###autoload
(defgroup annotate nil
"Annotate files without changing them."
- :version "0.7.0"
+ :version "0.8.0"
:group 'text)
;;;###autoload
@@ -2489,5 +2489,54 @@ annotation, like this:
;;;; end of filtering: parser, lexer, etc.
+;;;; switching database
+
+(defun annotate-buffers-annotate-mode ()
+ "Returns a list of all the buffers that have
+annotate minor mode active"
+ (let ((all-buffers (buffer-list)))
+ (cl-labels ((annotate-mode-p (buffer)
+ (with-current-buffer buffer
+ (and (boundp 'annotate-mode)
+ annotate-mode))))
+ (cl-remove-if-not #'annotate-mode-p all-buffers))))
+
+(cl-defun annotate-switch-db (&optional (force-load nil))
+ "Ask the user for a new annotation database files, load it and
+refresh all the annotations contained in each buffer where
+annotate minor mode is active.
+
+If `force-load' is non nil no prompt asking user for confirmation
+about loading the new file is shown.
+
+Note: this function will attempt to load (compile and
+eval/execute) the content of the file as it was elisp source
+code, always use load files from trusted sources!"
+ (interactive)
+ (let ((new-db (read-file-name "Database file location: ")))
+ (when (not (annotate-string-empty-p new-db))
+ (if (file-exists-p new-db)
+ (let* ((confirm-message "Loading elisp file from untrusted source
may results in severe security problems. Load %S? [y/N] ")
+ (load-file-confirmed (if force-load
+ t
+ (string= (read-from-minibuffer (format
confirm-message
+
new-db))
+ "y"))))
+ (if load-file-confirmed
+ (progn
+ (setf annotate-file new-db)
+ (cl-loop for annotated-buffer in
(annotate-buffers-annotate-mode) do
+ (with-current-buffer annotated-buffer
+ (let ((buffer-was-modified-p (buffer-modified-p
annotated-buffer)))
+ (annotate-with-inhibit-modification-hooks
+ (annotate-mode -1)
+ (annotate-mode 1)
+ (when (not buffer-was-modified-p)
+ (set-buffer-modified-p nil)))))))
+ (message "Load aborted by the user")))
+ (user-error (format "The file %S does not exists." new-db))))))
+
+;; end of switching database
+
(provide 'annotate)
;;; annotate.el ends here
- [nongnu] elpa/annotate 1525550f85 182/372: - changed test for annotation rejection and removed (maybe) useless check., (continued)
- [nongnu] elpa/annotate 1525550f85 182/372: - changed test for annotation rejection and removed (maybe) useless check., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2e858729cb 200/372: - saving annotations with newlines seems to works;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 31e3c24726 195/372: - updated version and documentation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e933d84692 214/372: - fixed removing of annotation in 'annotate-before-change-fn', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e03edfb2c2 218/372: - increased version number;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e2c365a376 222/372: - added reference to the issue., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 44b378b16a 219/372: Merge pull request #62 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f0a71bb148 223/372: Merge pull request #64 from cage2/fix-face-detection, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 8ac52808e8 226/372: - added a couple of functions to allow an user to change the file that, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9ea6c4fc71 247/372: - signalled errors when query parsing errors occurs., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate cc0b5da6c1 229/372: Merge pull request #69 from cage2/switch-database,
ELPA Syncer <=
- [nongnu] elpa/annotate 914c9ee5b9 264/372: Fixed a regression and some bugs related to incorrect calculation of, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0b71184865 269/372: - updated changelog., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3b4ee73c8d 275/372: - stored abbreviated filenames for the path component of each record, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c4a56cc33d 306/372: - added missing argument to 'annotate-create-annotation'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9fc6d7a839 311/372: - allowed deleting of annotations for info files., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 54ac759fac 315/372: Merge pull request #99 from cage2/remove-some-compilation-warnings, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4ae1d4f2a6 346/372: Merge pull request #112 from cage2/clean-style, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 8471cdaa7c 328/372: - updated Changelog., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0e5ccfdb4e 326/372: - replaced 'if' with 'when' when no 'else' branch exists., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7871adfbd8 320/372: - skipped file left with no annotations when saving., ELPA Syncer, 2022/02/04