[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/why-this 41fe21da73 15/59: Fontify before annotate
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/why-this 41fe21da73 15/59: Fontify before annotate |
Date: |
Sun, 27 Nov 2022 16:02:49 -0500 (EST) |
branch: elpa/why-this
commit 41fe21da73482747e686e51ce625b36657a26466
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Fontify before annotate
---
why-this.el | 192 ++++++++++++++++++++++++++++++------------------------------
1 file changed, 97 insertions(+), 95 deletions(-)
diff --git a/why-this.el b/why-this.el
index 67b7827ced..63bf3ae453 100644
--- a/why-this.el
+++ b/why-this.el
@@ -341,101 +341,103 @@ Actually the supported backend is returned."
"Annotate current buffer with editing history."
(interactive)
(let ((backend (why-this-supported-p)))
- (if backend
- (let* ((line-count (line-number-at-pos (1- (point-max))))
- (data (funcall backend 'line-data 1 (1+ line-count)))
- (contents (split-string (buffer-substring (point-min)
- (point-max))
- "\n"))
- (i 0)
- (change-times (mapcar
- (lambda (line)
- (float-time (plist-get line :time)))
- data))
- (newest-change (apply #'max change-times))
- (oldest-change (apply #'min change-times))
- (last-change-begin 0)
- (add-heat
- (lambda ()
- (let (ov)
- (setq ov (make-overlay last-change-begin (point)))
- (overlay-put ov 'face
- `(:background
- ,(why-this--mix-colors
- why-this-annotate-heat-map-cold
- why-this-annotate-heat-map-warm
- (if (equal newest-change
- oldest-change)
- 0.5
- (/ (- (float-time
- (plist-get (nth (1- i) data)
- :time))
- oldest-change)
- (- newest-change
- oldest-change))))
- :extend t))))))
- (with-current-buffer (get-buffer-create
- (format "*why-this-annotate %s*"
- (buffer-name)))
- (why-this-annotate-mode)
- (setq buffer-read-only nil)
- (erase-buffer)
- (dolist (line data)
- (if (and (not (zerop i))
- (equal (plist-get line :id)
- (plist-get (nth (1- i) data) :id)))
- (insert
- (format (format "%%%is" why-this-annotate-length) "")
- why-this-annotate-separator
- (format (format "%%%ii" (length (number-to-string
- line-count)))
- (1+ i))
- " "
- (nth i contents)
- "\n")
- (unless (zerop i)
- (let (ov)
- (setq ov (make-overlay (line-beginning-position 0)
- (point)))
- (overlay-put ov 'face `(:underline
- ,(face-foreground 'default)
- :extend t)))
- (when why-this-annotate-enable-heat-map
- (funcall add-heat)))
- (setq last-change-begin (point))
- (let* ((time (why-this-relative-time
- (plist-get line :time)))
- (author (format
- (format "%%-%is"
- why-this-annotate-author-length)
- (plist-get line :author)))
- (message-length (- why-this-annotate-length
- why-this-annotate-author-length
- (length time) 4))
- (message (format
- (format "%%-%is" message-length)
- (plist-get line :message))))
- (why-this--insert-and-truncate
- author why-this-annotate-author-length)
- (insert " ")
- (why-this--insert-and-truncate message message-length)
- (insert
- " "
- time
- why-this-annotate-separator
- (format (format "%%%ii" (length (number-to-string
- line-count)))
- (1+ i))
- " "
- (nth i contents)
- "\n")))
- (setq i (1+ i)))
- (when why-this-annotate-enable-heat-map
- (funcall add-heat))
- (setq buffer-read-only t)
- (goto-char (point-min))
- (display-buffer (current-buffer))))
- (user-error "No backend"))))
+ (if (not backend)
+ (user-error "No backend")
+ (save-excursion
+ (font-lock-fontify-region (point-min) (point-max)))
+ (let* ((line-count (line-number-at-pos (1- (point-max))))
+ (data (funcall backend 'line-data 1 (1+ line-count)))
+ (contents (split-string (buffer-substring (point-min)
+ (point-max))
+ "\n"))
+ (i 0)
+ (change-times (mapcar
+ (lambda (line)
+ (float-time (plist-get line :time)))
+ data))
+ (newest-change (apply #'max change-times))
+ (oldest-change (apply #'min change-times))
+ (last-change-begin 0)
+ (add-heat
+ (lambda ()
+ (let (ov)
+ (setq ov (make-overlay last-change-begin (point)))
+ (overlay-put ov 'face
+ `(:background
+ ,(why-this--mix-colors
+ why-this-annotate-heat-map-cold
+ why-this-annotate-heat-map-warm
+ (if (equal newest-change
+ oldest-change)
+ 0.5
+ (/ (- (float-time
+ (plist-get (nth (1- i) data)
+ :time))
+ oldest-change)
+ (- newest-change
+ oldest-change))))
+ :extend t))))))
+ (with-current-buffer (get-buffer-create
+ (format "*why-this-annotate %s*"
+ (buffer-name)))
+ (why-this-annotate-mode)
+ (setq buffer-read-only nil)
+ (erase-buffer)
+ (dolist (line data)
+ (if (and (not (zerop i))
+ (equal (plist-get line :id)
+ (plist-get (nth (1- i) data) :id)))
+ (insert
+ (format (format "%%%is" why-this-annotate-length) "")
+ why-this-annotate-separator
+ (format (format "%%%ii" (length (number-to-string
+ line-count)))
+ (1+ i))
+ " "
+ (nth i contents)
+ "\n")
+ (unless (zerop i)
+ (let (ov)
+ (setq ov (make-overlay (line-beginning-position 0)
+ (point)))
+ (overlay-put ov 'face `(:underline
+ ,(face-foreground 'default)
+ :extend t)))
+ (when why-this-annotate-enable-heat-map
+ (funcall add-heat)))
+ (setq last-change-begin (point))
+ (let* ((time (why-this-relative-time
+ (plist-get line :time)))
+ (author (format
+ (format "%%-%is"
+ why-this-annotate-author-length)
+ (plist-get line :author)))
+ (message-length (- why-this-annotate-length
+ why-this-annotate-author-length
+ (length time) 4))
+ (message (format
+ (format "%%-%is" message-length)
+ (plist-get line :message))))
+ (why-this--insert-and-truncate
+ author why-this-annotate-author-length)
+ (insert " ")
+ (why-this--insert-and-truncate message message-length)
+ (insert
+ " "
+ time
+ why-this-annotate-separator
+ (format (format "%%%ii" (length (number-to-string
+ line-count)))
+ (1+ i))
+ " "
+ (nth i contents)
+ "\n")))
+ (setq i (1+ i)))
+ (when why-this-annotate-enable-heat-map
+ (funcall add-heat))
+ (setq buffer-read-only t)
+ (goto-char (point-min))
+ (display-buffer (current-buffer)))))))
;;;###autoload
(define-minor-mode why-this-mode
- [nongnu] elpa/why-this f62dccdd90 10/59: Add annonation support, (continued)
- [nongnu] elpa/why-this f62dccdd90 10/59: Add annonation support, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 340194b6d2 24/59: Calculate background for message, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 167397e7ad 25/59: Fix copyright year, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9c0daa799c 28/59: Rename a variable, change backend API and update docs, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 53b2b803f0 22/59: Update commentary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this d47f547250 39/59: Allow customization of executable paths, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7f1ae28159 36/59: Fix Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 9f656b59dd 33/59: Change package summary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3497115c2b 35/59: Don't store unnecessary data, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7a2e4af450 19/59: Rewrite Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 41fe21da73 15/59: Fontify before annotate,
ELPA Syncer <=
- [nongnu] elpa/why-this 006ea3864a 13/59: Fix Git backend 'supported-p command, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 0c1686d8d3 12/59: Fix misspelled word "annonate", ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 73398fb7cb 04/59: Don't interfere with writing, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 2093cadb03 06/59: Add relative time support and fix Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this c2a21ca13d 01/59: Core implementation without any backends, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this b26fca274d 21/59: Add COPYING, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 88ee5f9746 27/59: Add Mercurial backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 624e98bc78 23/59: Fix relative time calculation, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 45dc65ccb1 26/59: Fix timezone problem in Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 236f8fd225 09/59: Fix problem when enabled on multiple buffers, ELPA Syncer, 2022/11/27