[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/annotate bf80059e7a 071/372: - use comment ends string in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/annotate bf80059e7a 071/372: - use comment ends string in modes that allow it (e.g. html-mode); |
Date: |
Fri, 4 Feb 2022 16:58:19 -0500 (EST) |
branch: elpa/annotate
commit bf80059e7ae3fe0fe0382b5c9f54d6888e0bf2c4
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>
- use comment ends string in modes that allow it (e.g. html-mode);
- when export a diff copy the mode of the parent buffer (i.e. the
annotated file) into the exported one.
---
annotate.el | 96 ++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 53 insertions(+), 43 deletions(-)
diff --git a/annotate.el b/annotate.el
index be9d50a475..ec40aa9a6c 100644
--- a/annotate.el
+++ b/annotate.el
@@ -211,6 +211,19 @@
(or comment-start
annotate-fallback-comment))
+(defun actual-comment-end ()
+ (or comment-end
+ ""))
+
+(defun comments-length ()
+ (+ (string-width (actual-comment-start))
+ (string-width (actual-comment-end))))
+
+(defun wrap-in-comment (&rest strings)
+ (apply #'concat (append (list (actual-comment-start))
+ strings
+ (list (actual-comment-end)))))
+
(defun annotate-integrate-annotations ()
"Write all annotations into the file as comments below the annotated line.
An example might look like this:"
@@ -232,10 +245,11 @@ An example might look like this:"
(point))))
(end-of-line)
(insert "\n"
- (actual-comment-start)
- (make-string (max 0 (- ov-start bol (length
(actual-comment-start)))) ? )
- (make-string (max 0 (- eol ov-start))
- annotate-integrate-higlight)))
+ (wrap-in-comment (make-string (max 0
+ (- ov-start bol
(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)
@@ -247,23 +261,22 @@ An example might look like this:"
(point))))
(end-of-line)
(insert "\n"
- (actual-comment-start)
- (make-string (max 0 (- eol bol (length
(actual-comment-start))))
- annotate-integrate-higlight))))
+ (wrap-in-comment (make-string (max 0
+ (- eol bol
(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"
- (actual-comment-start)
- (make-string (max 0 (- ov-end bol (length
(actual-comment-start))))
- annotate-integrate-higlight)))
+ (wrap-in-comment (make-string (max 0
+ (- ov-end bol
(comments-length)))
+ annotate-integrate-higlight))))
;; insert actual annotation text
(insert "\n"
- (actual-comment-start)
- annotate-integrate-marker
- (overlay-get ov 'annotation)))
+ (wrap-in-comment annotate-integrate-marker
+ (overlay-get ov 'annotation))))
;; overlay is within one line
(t
(let* ((ov-start (overlay-start ov))
@@ -277,13 +290,13 @@ An example might look like this:"
annotate-integrate-higlight))))
(end-of-line)
(insert "\n"
- (actual-comment-start)
- (make-string (max 0 (- ov-start bol (length
(actual-comment-start)))) ? )
- underline-marker
+ (wrap-in-comment (make-string (max 0
+ (- ov-start bol
(comments-length)))
+ ? )
+ underline-marker)
"\n"
- (actual-comment-start)
- annotate-integrate-marker
- (overlay-get ov 'annotation)))))
+ (wrap-in-comment annotate-integrate-marker
+ (overlay-get ov 'annotation))))))
(remove-text-properties
(point) (1+ (point)) '(display nil)))))
@@ -307,12 +320,14 @@ This diff does not contain any changes, but highlights the
annotation, and can be conveniently viewed in diff-mode."
(interactive)
(let* ((filename (substring-no-properties (or (buffer-file-name) "")))
- (export-buffer (generate-new-buffer (concat
- filename
- ".annotations.diff")))
- (annotations (annotate-describe-annotations)))
+ (export-buffer (generate-new-buffer (concat
+ filename
+ ".annotations.diff")))
+ (annotations (annotate-describe-annotations))
+ (parent-buffer-mode major-mode))
;; write the diff file description
(with-current-buffer export-buffer
+ (funcall parent-buffer-mode)
(let ((time-string
(format-time-string "%F %H:%M:%S.%N %z"
(nth 5 (file-attributes filename 'integer)))))
@@ -357,13 +372,12 @@ annotation, and can be conveniently viewed in diff-mode."
((= (length annotation-line-list) 1)
(insert (car annotation-line-list) "\n")
(unless (string= (car annotation-line-list) "+")
- (insert (actual-comment-start)
- (make-string (- start bol) ? )
- (make-string (- end start)
annotate-integrate-higlight)
+ (insert (wrap-in-comment (make-string (- start bol) ? )
+ (make-string (- end start)
+
annotate-integrate-higlight))
"\n"))
- (insert (actual-comment-start)
- (make-string (- start bol) ? )
- text
+ (insert (wrap-in-comment (make-string (- start bol) ? )
+ text)
"\n"))
;; annotation has more than one line
(t
@@ -372,34 +386,30 @@ annotation, and can be conveniently viewed in diff-mode."
(insert line "\n")
;; underline highlight (from start to eol)
(unless (string= line "+") ; empty line
- (insert (actual-comment-start)
- (make-string (- start bol) ? )
- (make-string (- (length line) (- start bol))
- annotate-integrate-higlight)
+ (insert (wrap-in-comment (make-string (- start bol) ? )
+ (make-string (- (length line) (-
start bol))
+
annotate-integrate-higlight))
"\n")))
(dolist (line (cdr (butlast annotation-line-list))) ; nth line
;; nth diff line
(insert line "\n")
;; nth underline highlight (from bol to eol)
(unless (string= line "+")
- (insert (actual-comment-start)
- (make-string (length line)
- annotate-integrate-higlight)
+ (insert (wrap-in-comment (make-string (length line)
+
annotate-integrate-higlight))
"\n")))
(let ((line (car (last annotation-line-list))))
;; last diff line
(insert line "\n")
;; last underline highlight (from bol to end)
(unless (string= line "+")
- (insert (actual-comment-start)
- (make-string (- (length line)
- (- eol end)
- 1)
- annotate-integrate-higlight)
+ (insert (wrap-in-comment (make-string (- (length line)
+ (- eol end)
+ 1)
+
annotate-integrate-higlight))
"\n")))
;; annotation text
- (insert (actual-comment-start)
- text
+ (insert (wrap-in-comment text)
"\n"))))
(insert (annotate-prefix-lines " " following-lines))))))
(switch-to-buffer export-buffer)
- [nongnu] elpa/annotate b22f594f3b 336/372: Merge pull request #107 from cage2/prevent-saving-empty-db, (continued)
- [nongnu] elpa/annotate b22f594f3b 336/372: Merge pull request #107 from cage2/prevent-saving-empty-db, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate de86b9b22e 341/372: - removed uses of regular expressions from 'annotate-unwrap-text'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e083073ead 371/372: - updated Changelog;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0901aa52bc 367/372: - added the others procedures to import an annotation database., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f08923762f 063/372: fix typo in documentation, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 16f7202d7c 091/372: - fixed docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 7c759ba9eb 082/372: - fixed english language error., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 47dba946e8 075/372: - removed spurious newline character at the end of annotation text;, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 91f1d49368 087/372: - squeezed contiguous spaces in docstring., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate f85f8e00a1 088/372: - remove file size limit for hash calculation., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate bf80059e7a 071/372: - use comment ends string in modes that allow it (e.g. html-mode);,
ELPA Syncer <=
- [nongnu] elpa/annotate f01b98de03 096/372: - restored the kill buffer key command., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 1313777f03 098/372: - added args to local function., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 0bbdbea410 095/372: - improved appereance of summary window, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate edaafc69a9 052/372: no more broken annotations with umlauts, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate c42db2cdf9 034/372: don't mark buffer as modified on load or clear, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate 38eb69da8b 107/372: - added a secondary color for highlight and annotation text, the two, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate af6d1bd39a 055/372: tiny bugfix, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate e77fc74bd2 036/372: change key binding to be more standard, ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate b032d2afe0 116/372: - changed function name: 'move-lines' -> 'beginning-of-nth-line'., ELPA Syncer, 2022/02/04
- [nongnu] elpa/annotate ce8dfa5ae9 110/372: - added docstrings., ELPA Syncer, 2022/02/04