[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate 8b06586497 282/372: - fixed integration of multil
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate 8b06586497 282/372: - fixed integration of multiline annotated text. |
Date: |
Fri, 4 Feb 2022 16:59:08 -0500 (EST) |
branch: elpa/annotate
commit 8b0658649718ffba6158000f9e080c952de4b16b
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- fixed integration of multiline annotated text.
---
annotate.el | 161 ++++++++++++++++++++++++++++++++----------------------------
1 file changed, 86 insertions(+), 75 deletions(-)
diff --git a/annotate.el b/annotate.el
index c1f8800a1a..4039b27454 100644
--- a/annotate.el
+++ b/annotate.el
@@ -699,87 +699,95 @@ annotate-actual-comment-end"
"Write all annotations into the file as comments below the annotated line.
An example might look like this:"
(interactive)
- (save-excursion
- (dolist (ov (sort (annotate-all-annotations)
- (lambda (o1 o2)
- (< (overlay-start o1)
- (overlay-start o2)))))
- (goto-char (overlay-start ov))
- (cond
- ;; overlay spans more than one line
- ((string-match "\n" (buffer-substring (overlay-start ov)
- (overlay-end ov)))
- ;; partially underline first line
- (let ((ov-start (point))
- (bol (progn (beginning-of-line)
- (point)))
- (eol (progn (end-of-line)
- (point))))
- (end-of-line)
- (insert "\n"
- (annotate-wrap-in-comment (make-string (max 0
- (- ov-start
- bol
-
(annotate-comments-length)))
- ? )
- (make-string (max 0 (- eol
ov-start))
-
annotate-integrate-higlight))))
- ;; fully underline second to second-to-last line
- (while (< (progn (forward-line)
- (end-of-line)
- (point))
- (overlay-end ov))
- (let ((bol (progn (beginning-of-line)
+ (cl-labels ((wrap-annotation-text (text)
+ (let* ((lines (annotate--split-lines text))
+ (commented-lines (mapcar 'annotate-wrap-in-comment
+ (append (list
annotate-integrate-marker)
+ lines))))
+ (annotate--join-with-string commented-lines "\n"))))
+ (save-excursion
+ (dolist (ov (sort (annotate-all-annotations)
+ (lambda (o1 o2)
+ (< (overlay-start o1)
+ (overlay-start o2)))))
+ (goto-char (overlay-start ov))
+ (cond
+ ;; overlay spans more than one line
+ ;; IMPORTANT NOTE:
+ ;; this branch is vestigial: a single annotation
+ ;; overlay can *not* spans for more that one line after
+ ;; chains has been introduced, therefore this code branch
+ ;; never runs and should be removed
+ ((string-match "\n" (buffer-substring (overlay-start ov)
+ (overlay-end ov)))
+ ;; partially underline first line
+ (let ((ov-start (point))
+ (bol (progn (beginning-of-line)
(point)))
(eol (progn (end-of-line)
(point))))
(end-of-line)
(insert "\n"
(annotate-wrap-in-comment (make-string (max 0
- (- eol
+ (- ov-start
bol
(annotate-comments-length)))
-
annotate-integrate-higlight)))))
- ;; partially underline last line
- (let ((bol (progn (beginning-of-line)
- (point)))
- (ov-end (overlay-end ov)))
- (end-of-line)
- (insert "\n"
- (annotate-wrap-in-comment (make-string (max 0
- (- ov-end
- bol
-
(annotate-comments-length)))
-
annotate-integrate-higlight))))
- ;; insert actual annotation text
- (insert "\n"
- (annotate-wrap-in-comment annotate-integrate-marker
- (overlay-get ov 'annotation))))
- ;; overlay is within one line
- (t
- (let* ((ov-start (overlay-start ov))
- (ov-end (overlay-end ov))
- (bol (progn (beginning-of-line)
- (point)))
- (underline-marker (if (= bol ov-start)
- (make-string (max 0 (- ov-end ov-start 1))
- annotate-integrate-higlight)
- (make-string (max 0 (- ov-end ov-start))
- annotate-integrate-higlight))))
- (end-of-line)
- (insert "\n"
- (annotate-wrap-in-comment (make-string (max 0
- (- ov-start
- bol
-
(annotate-comments-length)))
- ? )
- underline-marker)
- "\n")
- (when (annotate-chain-last-p ov)
- (let ((annotation-integrated-text (annotate-wrap-in-comment
annotate-integrate-marker
-
(overlay-get ov 'annotation))))
- (insert annotation-integrated-text)))))))
- (annotate-clear-annotations)))
+ ? )
+ (make-string (max 0 (- eol
ov-start))
+
annotate-integrate-higlight))))
+ ;; fully underline second to second-to-last line
+ (while (< (progn (forward-line)
+ (end-of-line)
+ (point))
+ (overlay-end ov))
+ (let ((bol (progn (beginning-of-line)
+ (point)))
+ (eol (progn (end-of-line)
+ (point))))
+ (end-of-line)
+ (insert "\n"
+ (annotate-wrap-in-comment (make-string (max 0
+ (- eol
+ bol
+
(annotate-comments-length)))
+
annotate-integrate-higlight)))))
+ ;; partially underline last line
+ (let ((bol (progn (beginning-of-line)
+ (point)))
+ (ov-end (overlay-end ov)))
+ (end-of-line)
+ (insert "\n"
+ (annotate-wrap-in-comment (make-string (max 0
+ (- ov-end
+ bol
+
(annotate-comments-length)))
+
annotate-integrate-higlight))))
+ ;; insert actual annotation text
+ (insert (wrap-annotation-text (overlay-get ov 'annotation))))
+ ;; overlay is within one line
+ (t
+ (let* ((ov-start (overlay-start ov))
+ (ov-end (overlay-end ov))
+ (bol (progn (beginning-of-line)
+ (point)))
+ (underline-marker (if (= bol ov-start)
+ (make-string (max 0 (- ov-end ov-start
1))
+
annotate-integrate-higlight)
+ (make-string (max 0 (- ov-end ov-start))
+
annotate-integrate-higlight))))
+ (end-of-line)
+ (insert "\n"
+ (annotate-wrap-in-comment (make-string (max 0
+ (- ov-start
+ bol
+
(annotate-comments-length)))
+ ? )
+ underline-marker))
+ (when (annotate-chain-last-p ov)
+ (let ((annotation-integrated-text (wrap-annotation-text
(overlay-get ov
+
'annotation))))
+ (insert "\n" annotation-integrated-text)))))))
+ (annotate-clear-annotations))))
(defun annotate-export-annotations ()
"Export all annotations as a unified diff file.
@@ -1034,6 +1042,10 @@ to 'maximum-width'."
(save-match-data
(split-string text "\n")))
+(defun annotate--join-with-string (strings junction)
+ (cl-reduce (lambda (a b) (concat a junction b))
+ strings))
+
(defun annotate-wrap-annotation-in-box (annotation-overlay
begin-of-line
end-of-line
@@ -1068,8 +1080,7 @@ a a**
padding-sizes))
(box-lines (cl-mapcar (lambda (a b) (concat a b))
lines paddings))
- (almost-boxed (cl-reduce (lambda (a b) (concat a
"\n" b))
- box-lines)))
+ (almost-boxed (annotate--join-with-string box-lines
"\n")))
(concat almost-boxed " "))))
(if annotation-on-is-own-line-p
(list (boxify-multiline))
- [nongnu] elpa/annotate 8ec9e0ea37 253/372: - increased version., (continued)
- [nongnu] elpa/annotate 8ec9e0ea37 253/372: - increased version., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c42686bab5 271/372: - allow overwriting (even partial) of annotations., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 9b824d23ec 267/372: - updated Changelog and NEWS.org., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e015655f62 255/372: - fixed version number contained in code top comment., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 2bf7a7c1ac 254/372: Merge pull request #77 from cage2/signalling-errors, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bd31608f50 260/372: - added command 'annotate-summary-of-file-from-current-pos', ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate a8857153ca 276/372: - extracted local function and taken into account info node names, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 12ad966a9d 278/372: - wrapped 'annotate-wrap-annotation-in-box' with 'save-match-data., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 401dab7723 291/372: - updated README, Changelog and version number., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 44ac24f63d 274/372: Merge pull request #87 from cage2/overwrite-annotations, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 8b06586497 282/372: - fixed integration of multiline annotated text.,
ELPA Syncer <=
- [nongnu] elpa/annotate 485060813b 277/372: - added procedures to pad multiline annotation text., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e004ae7e97 281/372: - updated version;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3e5d14fde8 287/372: - updated documentation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 6415fb6111 294/372: - updated NEWS and CHANGELOG;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 4890d2d2a2 295/372: Merge pull request #95 from cage2/master, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 85d7c87e08 293/372: - added padding also for notes placed on the margin of the window., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ac55086d60 301/372: - fixed typo., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 3415b7ac08 321/372: - changed behaviour when user is annotation a newline character;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f33eecba7b 362/372: - prevented asking to delete a database that does not actually exists, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1350e1d073 338/372: - fixed annotated text shown in the summary window, ELPA Syncer, 2022/02/04