Error progress, thoughts enumerated and font references corrected

master
Brady McDonough 3 years ago
parent c5bfdab476
commit fa2c6c899b

@ -49,6 +49,15 @@
;;; Code: ;;; Code:
;;; -*- lexical-binding: t -*- ;;; -*- 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 ;; Optional
(require 'icicles nil t) (require 'icicles nil t)
@ -108,40 +117,38 @@
:group 'faces :group 'faces
:prefix "tacc-") :prefix "tacc-")
;; Font/face inheritance is not well described anywhere in the elisp programming manual
;; Check emacs user manual?
(defface tacc-graph-work (defface tacc-graph-work
'((t (:inherit 'success))) '((t :inherit success))
"For work graph bars" "For work graph bars"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-graph-break (defface tacc-graph-break
'((t (:inherit 'warning))) '((t :inherit warning))
"For break graph bars" "For break graph bars"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-graph-void (defface tacc-graph-void
'((t (:inherit 'shadow))) '((t :inherit shadow))
"For filler graph bars" "For filler graph bars"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-clock (defface tacc-clock
'((t (:height 3.0))) '((t :height 3.0))
"For the clock and timer" "For the clock and timer"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-clock-pause (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" "For the timer while the timer isn't running"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-overwork (defface tacc-overwork
'((t (:inherit (tacc-clock error)))) '((t :inherit (tacc-clock error)))
"for the timer whenever we are in overwork" "for the timer whenever we are in overwork"
:group 'tacc-faces) :group 'tacc-faces)
(defface tacc-tag (defface tacc-tag
'((t (:inherit 'link-visited))) '((t :inherit link-visited))
"The face the tag is printed in" "The face the tag is printed in"
:group 'tacc-faces) :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))))) (+ len (if (<= ticker rem) 1 0)))))
(defun gradient-string (width chars) (defun gradient-string (width chars)
;; ERROR: If I'm not mistaken mapconcat internally uses a call to eval ;; (mapconcat (let ((ticker 0)
;; In order for eval to respect lexical binding rules rather than dynamic ones ;; (rem (mod width (length chars)))
;; it requires an optional argument to enable the feature. ;; (len (/ width (length chars))))
;; A look at the source is required and maybe a less "clever" solution should be found ;; (lambda (c)
(mapconcat (let ((ticker 0) ;; (make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
(rem (mod width (length chars))) ;; c)))
(len (/ width (length chars)))) ;; chars ""))
(lambda (c) (make-string width (aref chars 0)))
(make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
c)))
chars ""))
(defun tacc-header-render (width) (defun tacc-header-render (width)
"Returns a string for the header of the tacc timer" "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) ((eq state 'pause) 'tacc-clock-pause)
('t 'tacc-clock)))) ('t 'tacc-clock))))
(concat (concat
(propertize (format-time-string "%T" now) 'tacc-clock) (propertize (format-time-string "%T" now) 'face 'tacc-clock)
(propertize (format-time-string count-fmt count-face)) (propertize (format-time-string count-fmt countdown) 'face count-face)
(propertize (tacc-clock-glyph state) 'tacc-clock)))) (propertize (tacc-clock-glyph state) 'face 'tacc-clock))))
(defun tacc-current-tag-render () (defun tacc-current-tag-render ()
"Draw the tag name" "Draw the tag name"
(concat "Tag: " (propertize (alist-get 'tag tacc-info "<None>") (concat "Tag: " (propertize (alist-get 'tag tacc-info "<None>")
'tacc-tag))) 'face 'tacc-tag)))
(defun tacc-graph-bar-render (width work break void) (defun tacc-graph-bar-render (width work break void)
"Return a graph bar width characters wide with the given proportions as \ "Return a graph bar width characters wide with the given proportions as \
@ -528,11 +532,11 @@ float"
(concat (concat
"" ""
(propertize (make-string (round (* width work)) tacc-graph-char) (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) (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) (propertize (make-string (round (* width void)) tacc-graph-char)
'tacc-graph-void) 'face 'tacc-graph-void)
" \n"))) " \n")))
(defun tacc-timer-buffer-update (state now) (defun tacc-timer-buffer-update (state now)

Loading…
Cancel
Save