 ;; Functions
 ;;
 
-;; Other required functions:
-;;  `doom-fix-unicode'  in core/core-defuns.el
-;;  `doom/project-root' in core/defuns/defuns-projectile.el
-
-(defun doom-flycheck-count (state)
+(defun doom-ml-flycheck-count (state)
   "Return flycheck information for the given error type STATE."
   (when (flycheck-has-current-errors-p state)
     (if (eq 'running flycheck-last-status-change)

;;

;; Where (py|rb)env version strings will be stored
(defvar-local doom--env-version nil)
(defvar-local doom--env-command nil)

;; Make certain unicode glyphs bigger for the mode-line.
;; FIXME Replace with all-the-icons?

      (cdr-safe (assq state (flycheck-count-errors flycheck-current-errors))))))

;; pyenv/rbenv version segment
(defvar doom-ml-env-version-hook '()
  "Hook that runs whenever the environment version changes (e.g. rbenv/pyenv)")

(defun doom-ml|env-update ()
  (when doom-ml--env-command
    (let ((default-directory (doom/project-root)))
      (let ((s (shell-command-to-string doom-ml--env-command)))
        (setq doom-ml--env-version (if (string-match "[ \t\n\r]+\\'" s)
                                    (replace-match "" t t s)
                                  s))
        (run-hook-with-args 'doom-ml-env-version-hook doom-ml--env-version)))))

(defmacro def-version-cmd! (modes command)
  "Define a COMMAND for MODE that will set `doom-ml--env-command' when that mode is
activated, which should return the version number of the current environment. It is used
by `doom-ml|env-update' to display a version number in the modeline. For instance:

  (def-version-cmd! ruby-mode \"ruby --version | cut -d' ' -f2\")

This will display the ruby version in the modeline in ruby-mode buffers. It is cached the
first time."
  (add-hook! (focus-in find-file) 'doom-ml|env-update)
  `(add-hook! ,modes (setq doom-ml--env-command ,command)))


;;
