emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/annotate d6a4fcc18e 035/372: add next-annotation and previ


From: ELPA Syncer
Subject: [nongnu] elpa/annotate d6a4fcc18e 035/372: add next-annotation and previous-annotation keys
Date: Fri, 4 Feb 2022 16:58:17 -0500 (EST)

branch: elpa/annotate
commit d6a4fcc18e1b4a761617247df3e0a3d3d5b7d307
Author: Bastian Bechtold <basti@bastibe.de>
Commit: Bastian Bechtold <basti@bastibe.de>

    add next-annotation and previous-annotation keys
---
 README.md   |  7 +++++++
 annotate.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index eed8b509c3..829e9402c6 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,17 @@ This package provides a minor mode `annotate-mode`, which 
can add annotations to
 
 With an active region, `C-c C-a` creates a new annotation for that region. 
With no active region, `C-c C-a` will create an annotation for the word under 
point. If point is on an annotated region, `C-c C-a` will edit that annotation 
instead of creating a new one. Clearing the annotation deletes them.
 
+Use `C-c C-n` to jump to the next annotation and `C-c C-p` to jump to the 
previous annotation.
+
 All annotations are saved in `annotate-file` (`~/.annotations` by default).
 
 Annotations can be exported `annotate-export-annotations` as commented unified 
diffs, like this:
 
 
![diff-example-screenshot](https://raw.githubusercontent.com/bastibe/annotate.el/master/diff-example.png)
 
+### Incompatibilities:
+
+- you can't annotate org-mode source code blocks.
+- `form-feed-mode`. For unknown reasons, `form-feed-mode` erases all 
annotations (to be more precise: the `display` text properties of the line feed 
characters, which is what `annotate` uses to display it's annotations).
+
 This package is released under the MIT license.
diff --git a/annotate.el b/annotate.el
index df761593d5..cb358ee530 100644
--- a/annotate.el
+++ b/annotate.el
@@ -5,7 +5,7 @@
 ;; Maintainer: Bastian Bechtold
 ;; URL: https://github.com/bastibe/annotate.el
 ;; Created: 2015-06-10
-;; Version: 0.2.4
+;; Version: 0.3.0
 
 ;; This file is NOT part of GNU Emacs.
 
@@ -39,6 +39,10 @@
 ;; To add annotations to a file, select a region and hit C-c C-a. The
 ;; region will be underlined, and the annotation will be displayed in
 ;; the right margin. Annotations are saved whenever the file is saved.
+;;
+;; Use C-c C-n to jump to the next annotation and C-c C-p to jump to
+;; the previous annotation. Use M-x annotate-export-annotations to
+;; save annotations as a no-difference diff file.
 
 ;;; Code:
 (require 'cl)
@@ -46,7 +50,7 @@
 ;;;###autoload
 (defgroup annotate nil
   "Annotate files without changing them."
-  :version "0.2.4"
+  :version "0.3.0"
   :group 'text)
 
 ;;;###autoload
@@ -61,6 +65,8 @@
                 (annotate-shutdown)))
 
 (define-key annotate-mode-map (kbd "C-c C-a") 'annotate-annotate)
+(define-key annotate-mode-map (kbd "C-c C-n") 'annotate-next-annotation)
+(define-key annotate-mode-map (kbd "C-c C-p") 'annotate-previous-annotation)
 
 ;;;###autoload
 (defcustom annotate-file "~/.annotations"
@@ -119,6 +125,49 @@
            (destructuring-bind (start end) (annotate-bounds)
              (annotate-create-annotation start end))))))
 
+;;;###autoload
+(defun annotate-next-annotation ()
+  "Move point to the next annotation."
+  (interactive)
+  ;; get all following overlays
+  (let ((overlays
+         (overlays-in (point) (buffer-size))))
+    ;; skip overlays not created by annotate.el
+    (setq overlays (remove-if
+                    (lambda (ov)
+                      (eq nil (overlay-get ov 'annotation)))
+                    overlays))
+    ;; skip properties under point
+    (dolist (current (overlays-at (point)))
+      (setq overlays (remove current overlays)))
+    ;; sort overlays ascending
+    (setq overlays (sort overlays (lambda (x y)
+                                    (< (overlay-start x) (overlay-start y)))))
+    (if (eq nil overlays)
+        (message "No further annotations.")
+      ;; jump to first overlay list
+      (goto-char (overlay-start (nth 0 overlays))))))
+
+;;;###autoload
+(defun annotate-previous-annotation ()
+  "Move point to the previous annotation."
+  (interactive)
+  ;; get all previous overlays
+  (let ((overlays
+         (overlays-in 0 (point))))
+    ;; skip overlays not created by annotate.el
+    (setq overlays (remove-if
+                    (lambda (ov)
+                      (eq nil (overlay-get ov 'annotation)))
+                    overlays))
+    ;; sort overlays descending
+    (setq overlays (sort overlays (lambda (x y)
+                                    (> (overlay-start x) (overlay-start y)))))
+    (if (eq nil overlays)
+        (message "No previous annotations.")
+      ;; jump to first overlay in list
+      (goto-char (overlay-start (nth 0 overlays))))))
+
 ;;;###autoload
 (defun annotate-save-annotations ()
   "Save all annotations to disk."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]