[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 9db834a 178/495: changes from CL
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 9db834a 178/495: changes from CL |
Date: |
Sat, 7 Aug 2021 09:05:08 -0400 (EDT) |
branch: elpa/go-mode
commit 9db834a9ee9bf74f729f61fbb0f65593e6044db3
Author: Dominik Honnef <dominikh@fork-bomb.org>
Commit: Dominik Honnef <dominikh@fork-bomb.org>
changes from CL
---
go-mode.el | 66 ++++++++++++++++++++++++++++++++------------------------------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/go-mode.el b/go-mode.el
index 832b2ed..35a6282 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1022,25 +1022,32 @@ current coverage buffer or by prompting for it."
go--coverage-origin-buffer
(current-buffer)))
-(defun go--coverage-make-overlay (range divisor)
- "Create a coverage overlay for a range of coverd/uncovered code."
+(defun go--coverage-face (count divisor)
+ "Return the intensity face for COUNT when using DIVISOR
+to scale it to a range [0,10].
+
+DIVISOR scales the absolute cover count to values from 0 to 10.
+For DIVISOR = 0 the count will always translate to 8."
(let* ((count (go--covered-count range))
(norm (cond
((= count 0)
- -0.1)
+ -0.1) ;; Uncovered code, set to -0.1 so n becomes 0.
((= divisor 0)
- 0.8)
+ 0.8) ;; covermode=set, set to 0.8 so n becomes 8.
(t
(/ (log count) divisor))))
- (n (1+ (floor (* norm 9))))
- (face (concat "go-coverage-" (number-to-string n)))
- (ov (make-overlay
- (go--line-column-to-point
- (go--covered-start-line range)
- (go--covered-start-column range))
- (go--line-column-to-point
- (go--covered-end-line range)
- (go--covered-end-column range)))))
+ (n (1+ (floor (* norm 9))))) ;; Convert normalized count [0,1] to
intensity [0,10]
+ (concat "go-coverage-" (number-to-string n))))
+
+(defun go--coverage-make-overlay (range divisor)
+ "Create a coverage overlay for a RANGE of covered/uncovered
+code. Uses DIVISOR to scale absolute counts to a [0,10] scale."
+ (let* ((count (go--covered-count range))
+ (face (go--coverage-face count divisor))
+ (ov (make-overlay (go--line-column-to-point (go--covered-start-line
range)
+ (go--covered-start-column
range))
+ (go--line-column-to-point (go--covered-end-line
range)
+ (go--covered-end-column
range)))))
(overlay-put ov 'face face)
(overlay-put ov 'help-echo (format "Count: %d" count))))
@@ -1049,16 +1056,14 @@ current coverage buffer or by prompting for it."
"Remove existing overlays and put a single untracked overlay
over the entire buffer."
(remove-overlays)
- (overlay-put
- (make-overlay
- (point-min)
- (point-max))
- 'face 'go-coverage-untracked))
+ (overlay-put (make-overlay (point-min) (point-max))
+ 'face
+ 'go-coverage-untracked))
(defun go--coverage-parse-file (coverage-file file-name)
"Parse COVERAGE-FILE and extract coverage information and
divisor for FILE-NAME."
- (let ((ranges '())
+ (let (ranges
(max-count 0))
(with-temp-buffer
(insert-file-contents coverage-file)
@@ -1070,20 +1075,18 @@ divisor for FILE-NAME."
(destructuring-bind
(start-line start-column end-line end-column num count)
- (mapcar 'string-to-number rest)
+ (mapcar #'string-to-number rest)
(when (and (string= (file-name-nondirectory file) file-name))
(if (> count max-count)
(setq max-count count))
- (push
- (make-go--covered
- :start-line start-line
- :start-column start-column
- :end-line end-line
- :end-column end-column
- :covered (/= count 0)
- :count count)
- ranges)))
+ (push (make-go--covered :start-line start-line
+ :start-column start-column
+ :end-line end-line
+ :end-column end-column
+ :covered (/= count 0)
+ :count count)
+ ranges)))
(forward-line)))
@@ -1104,9 +1107,8 @@ for."
(ranges-and-divisor (go--coverage-parse-file
coverage-file
(file-name-nondirectory (buffer-file-name
origin-buffer)))))
- (with-current-buffer (or
- (get-buffer gocov-buffer-name)
- (make-indirect-buffer origin-buffer
gocov-buffer-name t))
+ (with-current-buffer (or (get-buffer gocov-buffer-name)
+ (make-indirect-buffer origin-buffer
gocov-buffer-name t))
(set (make-local-variable 'go--coverage-origin-buffer) origin-buffer)
(set (make-local-variable 'go--coverage-current-file-name) coverage-file)
- [nongnu] elpa/go-mode c2b4441 155/495: Require ring so that we don't rely on a transitive require, (continued)
- [nongnu] elpa/go-mode c2b4441 155/495: Require ring so that we don't rely on a transitive require, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8a1c5df 159/495: minor style changes from CL, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 96eb71e 153/495: fix godef-jump on Windows, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4e92adb 150/495: add godef-jump-other-window, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2f67998 160/495: don't change point in go--line-column-to-point, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f79120b 166/495: add support for mode=count coverage, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 1d5ddda 167/495: add coverage count as a tooltip, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode eaa47c2 165/495: remove old overlays, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 210bb30 174/495: go-coverage: only update max-count if it's a count for the file we're interested in, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 38f2465 164/495: display a helpful prompt in go-coverage, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9db834a 178/495: changes from CL,
ELPA Syncer <=
- [nongnu] elpa/go-mode f1c266d 172/495: enable godef to work in coverage buffers, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 4b1c93f 173/495: use error instead of message in godef--call, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 68e9626 177/495: fully implement prog-mode for older emacsen, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7694963 181/495: detect stale coverage reports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 520f070 182/495: allow users to customize path of 'go' tool., ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 303ba8c 180/495: reformat code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode ab6853d 183/495: use (buffer-base-buffer) instead of own local variable, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode de4e59a 194/495: require at least one space after "type", ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 9fde5fb 189/495: godef-jump: support jumping to package directories, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 7878794 187/495: send the correct content-length to the playground, ELPA Syncer, 2021/08/07