这个feature,我最终期望的效果是这样的,还要继续琢磨下。 ,感谢你们已经帮我解决了遇到的最大的问题了。
还有一个问题,时间那一列,太占用空间了,最好是像git log 打印 x min ago, y hours ago这种,不知道有没有现有的函数可以使用?像这样
这个feature,我最终期望的效果是这样的,还要继续琢磨下。 ,感谢你们已经帮我解决了遇到的最大的问题了。
还有一个问题,时间那一列,太占用空间了,最好是像git log 打印 x min ago, y hours ago这种,不知道有没有现有的函数可以使用?像这样
既然要分成不同列,那就把它做成一个列表,然后后面再去处理:
(mapcar
(lambda (elem)
(let* ((short (car elem))
(long (cadr elem))
(score (magit-gerrit-trans-score
long (cdr (assoc long type-values)))))
(format "%s:%-2s" short score)))
magit-gerrit-review-labels)
但是这个括号有点诡异,不知道来自哪里。。
(defun magit-gerrit-wash-approvals-oneline (approvals)
(let* (type-values)
(seq-doseq (approval approvals)
(let ((type (cdr (assq 'type approval)))
(value (string-to-number (cdr (assq 'value approval)))))
(push value (alist-get type type-values nil nil #'string-equal))))
(mapcar
(lambda (elem)
(let* ((long (car elem))
(short (cadr elem))
(score (magit-gerrit-trans-score
long (cdr (assoc long type-values)))))
(format "%-2s" score)))
magit-gerrit-review-labels)
))
改成 mapconcat ok了,添加了 face。总体还算nice,代码还有很大的优化空间
(defun magit-gerrit-trans-score (type value-list)
(if (and value-list (length> value-list 0))
(let ((min-v (apply 'min value-list))
(max-v (apply 'max value-list))
(t-max-v 1)
(t-min-v -1))
(if (string= "Code-Review" type)
(setq t-max-v 2 t-min-v -2))
(cond
((<= min-v t-min-v) (propertize "x" 'face 'magit-signature-bad))
((>= max-v t-max-v) (propertize "√" 'face 'magit-signature-good))
((> min-v 0) (propertize (format "+%d" min-v) 'face 'magit-signature-good))
(t (propertize (format "%d" min-v) 'face 'magit-signature-bad))))
" "))
(defun magit-gerrit-wash-approvals-oneline (approvals)
(let* (type-values)
(seq-doseq (approval approvals)
(let ((type (cdr (assq 'type approval)))
(value (string-to-number (cdr (assq 'value approval)))))
(push value (alist-get type type-values nil nil #'string-equal))))
(mapconcat
(lambda (elem)
(let* ((long (car elem))
(short (cadr elem))
(score (magit-gerrit-trans-score
long (cdr (assoc long type-values)))))
(format "%-2s" score)))
magit-gerrit-review-labels
" ")))