 
 ;; code to discern whether mode line is being rendered on the active
 ;; window taken from https://emacs.stackexchange.com/a/26345
+
+;;; Code:
 
 (require 'battery)
 (require 'cl-lib)

(add-hook 'buffer-list-update-hook 'tnml-update-all)

(defun tnml/evil-module ()
  "Returns the current evil-state"
  (cond
   ((string-equal evil-state 'normal)
    (propertize " NORMAL "

			:weight ultra-bold)))))

(defun tnml/writable-module ()
  "Return a formatted string consisting of an icon representing the current buffer's status and its name."
  (mapc (lambda (icon-pair)
	    (if (eval (car icon-pair))
			(setq module-icon (propertize (eval (cdr icon-pair))
										  'face `(:family ,(all-the-icons-octicon-family)
														  :height 1.0)
										  'display '(raise -0.1)))))
	  '((t . (all-the-icons-material "edit"))
	    (buffer-read-only . (all-the-icons-material "lock"))
	    ((buffer-modified-p) . (all-the-icons-material "save"))
	    ((string-equal (symbol-name (symbol-value 'major-mode)) "eshell-mode") . (all-the-icons-alltheicon "terminal"))))

  (setq unformatted-string (concat " "
								   module-icon
								   " " (buffer-name) " "))

  (if (eq tnml-selected-window (selected-window))
	  (propertize unformatted-string
				   'face '(:background "dark magenta"
									   :foreground "white"))
	(propertize unformatted-string
				'face 'mode-line-inactive)))

(defun tnml/major-mode-module ()
  "Return the current major mode without the '-mode' suffix."
  (concat " "
		  (let ((mode-string (symbol-name (symbol-value 'major-mode))))
			(substring mode-string 0 (string-match "-mode$" mode-string)))
		  " "))

(defun tnml/position-module ()
  "Return a formatted string of percentage of where point is in buffer, line number, and column number."
  (setq unf-str (concat " "
		      (int-to-string (floor
				      (* (/ (float (point))
					    (point-max))
