July 8th 2026 - Things I Worked On

Added getting subtring to Hith

Using format and nth, which are already bult in, we can accumulate each character intro a string.

(defun substring (string start end)
  (defvar accum "")
  (range i start end
         (setq accum (format "%s%s" accum (nth i string))))
  accum)

(substring "test" 1 3)
;; => "es"

Added append, push, and reverse to Hith

(defvar list '(1 2 3))

(push 0 list)
;; => (0 1 2 3)

(append 4 list)
;; => (1 2 3 4)

(reverse list)
;; => (3 2 1)

Added split-string to Hith

(defvar x "test")
(split-string x "e")
;; => ("t" "st")

Added string-to-number to Hith

(string-to-number "10")
;; => 10

(string-to-number "10.23")
;; => 10.23

(string-to-number "test")
;; => nil

Added repeat to Hith

(defvar hits 0)
(repeat 2 (setq hits (+ hits 1)))
hits
;; => 2

Added unless to Hith

(unless (> 1 2) 1)
;; => 1

Added and and or to Hith

(and t 1 (+ 2 3))
;; => 5

(or (> 1 1) (+ 1 2))
;; => 3

Added converting currency in expenses

I track my cash expenses on my phone and twice a week I update my budget. I pull the expenses into Emacs but I still have to manually convert from Pesos to USD. I added this code to do conversion automatically when pulling the expenses.

(defun budget--get-line ()
  "Convenience function to get the whole line where pointer is located."
  (buffer-substring-no-properties (line-beginning-position) (line-end-position)))

(defun budget--convert-currency ()
  "Append the converted currency to the end of each expense."
  (let ((conversion-rate (read-number "Currency conversion rate: "))
        (at-end-of-file nil))

    (save-excursion
      (goto-char (point-min))

      (while (not at-end-of-file)
        (let* ((line (budget--get-line))
               (parts (split-string line " "))
               (value (string-to-number (car (last parts))))
               (converted (/ value conversion-rate)))

          (goto-char (line-end-position))
          (insert (format " -- %.2f" converted))

          (setq at-end-of-file (eobp))
          (unless at-end-of-file
            (next-line)))))))

Added moving deleted files to trash

By default Emacs deletes files off your system. We can set this variable to t to move files to the system Trash instead.

(setq delete-by-moving-to-trash t)