[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 39fc4bbda2 090/372: - added an annotation summary
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 39fc4bbda2 090/372: - added an annotation summary window |
Date: |
Fri, 4 Feb 2022 16:58:21 -0500 (EST) |
branch: elpa/annotate
commit 39fc4bbda2bb84c038e1be248ddce277d8b7a559
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- added an annotation summary window
the command 'annotate-show-annotation-summary' popup a window
containing a textual description of the annotations found in the
annotation file (like ~/.emacs/annotations) with the format:
-------
/path/of/an/annotated/file
- annotation text
- annotation text
/another/path/of/an/annotated/file
- annotation text
...
-------
Each annotation text is a link that, if activated (via a mouse click,
for example), opens a buffer showing the annotated file at the
position of the annotated text (the underlined one) linked to
annotation.
---
annotate.el | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/annotate.el b/annotate.el
index 276dffd95c..e113a5d3de 100644
--- a/annotate.el
+++ b/annotate.el
@@ -66,6 +66,8 @@
(define-key annotate-mode-map (kbd "C-c C-a") 'annotate-annotate)
+(define-key annotate-mode-map (kbd "C-c C-s")
'annotate-show-annotation-summary)
+
(define-key annotate-mode-map (kbd "C-c ]") 'annotate-next-annotation)
(define-key annotate-mode-map (kbd "C-c [") 'annotate-previous-annotation)
@@ -128,6 +130,11 @@ major mode is a member of this list (space separated
entries)."
:type '(repeat symbol)
:group 'annotate)
+(defcustom annotate-summary-link-max-width 64
+ "Cut the link text in a summary windows to this maximum size (in character)"
+ :type 'number
+ :group 'annotate)
+
(defun annotate-initialize-maybe ()
"Initialize annotate mode only if buffer's major mode is not in the
blacklist (see:
'annotate-blacklist-major-mode'"
@@ -730,6 +737,25 @@ file."
file."
(nth 1 record))
+(defun annotate-filename-from-dump (record)
+ "Get the filename field from an annotation list loaded from a
+file."
+ (cl-first record))
+
+(defun annotate-start-annotation-dump (annotation)
+ "Get the starting point of an annotation. The arg 'annotation' must be a
single
+annotation field got from a file dump of all annotated buffers,
+essentially what you get from:
+(annotate-annotations-from-dump (annotate-load-annotations))). "
+ (cl-first annotation))
+
+(defun annotate-text-annotation-dump (annotation)
+ "Get the text of an annotation. The arg 'annotation' must be a single
+annotation field got from a file dump of all annotated buffers,
+essentially what you get from:
+(annotate-annotations-from-dump (annotate-load-annotations))). "
+ (nth 2 annotation))
+
(defun annotate-load-annotation-old-format ()
"Load all annotations from disk in old format."
(interactive)
@@ -896,5 +922,48 @@ file."
(with-temp-file annotate-file
(prin1 data (current-buffer))))
+(define-button-type 'annotate-summary-button
+ 'follow-link t
+ 'help-echo "Click to show")
+
+(defun annotate-summary-button-pressed (button)
+ "Callback called when a sunmmary button is activated"
+ (let ((buffer (find-file-other-window (button-get button 'file))))
+ (with-current-buffer buffer
+ (goto-char (button-get button 'go-to)))))
+
+(defun annotate-show-annotation-summary ()
+ "Show a summary of all the annotations in a temp buffer"
+ (interactive)
+ (cl-labels ((ellipsize (text)
+ (if (> (string-width text)
+ annotate-summary-link-max-width)
+ (concat (subseq text 0 (-
annotate-summary-link-max-width 3))
+ "...")
+ text)))
+ (with-temp-buffer-window
+ "*annotations*" nil nil
+ (with-current-buffer "*annotations*"
+ (use-local-map nil)
+ (local-set-key "q" (lambda ()
+ (interactive)
+ (kill-buffer "*annotations*")))
+ (let ((dump (annotate-load-annotation-data)))
+ (dolist (annotation dump)
+ (let ((all-annotations (annotate-annotations-from-dump annotation))
+ (filename (annotate-filename-from-dump annotation)))
+ (when (not (null all-annotations))
+ (insert (format "%s\n\n" filename))
+ (dolist (annotation-field all-annotations)
+ (let ((button-text (format "%s"
+ (annotate-text-annotation-dump
annotation-field))))
+ (insert "- ")
+ (insert-button (propertize (ellipsize button-text) 'face
'bold)
+ 'file filename
+ 'go-to (annotate-start-annotation-dump
annotation-field)
+ 'action 'annotate-summary-button-pressed
+ 'type 'annotate-summary-button)
+ (insert "\n\n")))))))))))
+
(provide 'annotate)
;;; annotate.el ends here
- [nongnu] elpa/annotate c103381862 280/372: - moved 'save-match-data' from the function that calls, (continued)
- [nongnu] elpa/annotate c103381862 280/372: - moved 'save-match-data' from the function that calls, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3b871f10f9 290/372: - prevented side effects of 'split-string', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f3ace011a2 286/372: - changed customizable variable related to exporting., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate d4eff870d9 292/372: Merge pull request #93 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 58525eb73a 307/372: - changed function calls from 'cl' package to the 'cl-lib' equivalents., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4abf492f05 297/372: - updated NEWS and CHANGELOG;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate faa9245414 329/372: - increased version number and updated documentations., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7eee85f7f9 070/372: - made the character under the annotated text (when exporting or integrating), ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6d74f53074 015/372: improve documentation and add license, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6b4b2b69d7 023/372: can now annotate long lines, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 39fc4bbda2 090/372: - added an annotation summary window,
ELPA Syncer <=
- [nongnu] elpa/annotate d84bfd56b8 103/372: Merge pull request #44 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 253b5e2d7b 118/372: - try to elaborate a bit more the function goal., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f806eff4cc 142/372: Merge pull request #49 from cage2/annotate-info-files, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 40bd336a96 037/372: fix cl-related errors, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e199c77598 027/372: export format is now a valid unified diff, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e8c9b33b4d 051/372: fix unicode annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 676d9863f9 048/372: fix undo bug, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4dc3e70920 059/372: fixes bug for too-wide characters, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate cb8de5081a 078/372: Merge pull request #42 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 80e6b31c78 084/372: - fixed docstring., ELPA Syncer, 2022/02/04