Error progress, thoughts enumerated and font references corrected

master
Brady McDonough 3 years ago
parent c5bfdab476
commit fa2c6c899b

@ -49,6 +49,15 @@
;;; Code:
;;; -*- lexical-binding: t -*-
;; TODOS:
;; ERROR: Attempting to draw the buffer spams *Messages* with "invalid face reference/attribute" errors
;; This appears to not be caused by my code? The invalid reference is to 't and quote and the invalid
;; attribute is :inherit 'warning.
;; Eliminating the reference to the 'warning face in my code does not eliminate the error, and
;; customize-faces properly displays tacc-graph-break as inheriting the 'warning face
;; ERROR: mapconcat doesn't seem to respect lexical binding which leaves me unable to use a closure for a ticker
;; For now the code which relies on this will be noop'd
;; Optional
(require 'icicles nil t)
@ -108,40 +117,38 @@
:group 'faces
:prefix "tacc-")
;; Font/face inheritance is not well described anywhere in the elisp programming manual
;; Check emacs user manual?
(defface tacc-graph-work
'((t (:inherit 'success)))
'((t :inherit success))
"For work graph bars"
:group 'tacc-faces)
(defface tacc-graph-break
'((t (:inherit 'warning)))
'((t :inherit warning))
"For break graph bars"
:group 'tacc-faces)
(defface tacc-graph-void
'((t (:inherit 'shadow)))
'((t :inherit shadow))
"For filler graph bars"
:group 'tacc-faces)
(defface tacc-clock
'((t (:height 3.0)))
'((t :height 3.0))
"For the clock and timer"
:group 'tacc-faces)
(defface tacc-clock-pause
'((t (:inherit (tacc-clock ansi-slow-blink))))
'((t :inherit (tacc-clock italic ansi-slow-blink)))
"For the timer while the timer isn't running"
:group 'tacc-faces)
(defface tacc-overwork
'((t (:inherit (tacc-clock error))))
'((t :inherit (tacc-clock error)))
"for the timer whenever we are in overwork"
:group 'tacc-faces)
(defface tacc-tag
'((t (:inherit 'link-visited)))
'((t :inherit link-visited))
"The face the tag is printed in"
:group 'tacc-faces)
@ -419,17 +426,14 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
(+ len (if (<= ticker rem) 1 0)))))
(defun gradient-string (width chars)
;; ERROR: If I'm not mistaken mapconcat internally uses a call to eval
;; In order for eval to respect lexical binding rules rather than dynamic ones
;; it requires an optional argument to enable the feature.
;; A look at the source is required and maybe a less "clever" solution should be found
(mapconcat (let ((ticker 0)
(rem (mod width (length chars)))
(len (/ width (length chars))))
(lambda (c)
(make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
c)))
chars ""))
;; (mapconcat (let ((ticker 0)
;; (rem (mod width (length chars)))
;; (len (/ width (length chars))))
;; (lambda (c)
;; (make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
;; c)))
;; chars ""))
(make-string width (aref chars 0)))
(defun tacc-header-render (width)
"Returns a string for the header of the tacc timer"
@ -512,14 +516,14 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
((eq state 'pause) 'tacc-clock-pause)
('t 'tacc-clock))))
(concat
(propertize (format-time-string "%T" now) 'tacc-clock)
(propertize (format-time-string count-fmt count-face))
(propertize (tacc-clock-glyph state) 'tacc-clock))))
(propertize (format-time-string "%T" now) 'face 'tacc-clock)
(propertize (format-time-string count-fmt countdown) 'face count-face)
(propertize (tacc-clock-glyph state) 'face 'tacc-clock))))
(defun tacc-current-tag-render ()
"Draw the tag name"
(concat "Tag: " (propertize (alist-get 'tag tacc-info "<None>")
'tacc-tag)))
'face 'tacc-tag)))
(defun tacc-graph-bar-render (width work break void)
"Return a graph bar width characters wide with the given proportions as \
@ -528,11 +532,11 @@ float"
(concat
""
(propertize (make-string (round (* width work)) tacc-graph-char)
'tacc-graph-work)
'face 'tacc-graph-work)
(propertize (make-string (round (* width break)) tacc-graph-char)
'tacc-graph-break)
'face 'tacc-graph-break)
(propertize (make-string (round (* width void)) tacc-graph-char)
'tacc-graph-void)
'face 'tacc-graph-void)
" \n")))
(defun tacc-timer-buffer-update (state now)

Loading…
Cancel
Save