Hello fellow TeXmacsers, I am trying to make it so that in math mode, putting a number after a letter makes it so that the number becomes the subscript of the letter. I have this script here that I pasted into the my-init-texmacs.scm file and restarted the program, but it is not doing anything.
(tm-define (auto-subscript-digit key)
;; Only apply in math mode
(if (equal? (tree-label (current-env)) 'math)
(let ((prev (get-env-before-cursor 1)))
(if (and (not (null? prev))
(char-alphabetic? (tree->char (car prev))))
(begin
;; Delete the previous character (the letter)
(delete-env-before-cursor 1)
;; Insert subscripted version
(insert (make-tree 'sub
(car prev)
(string->tree key))))
(insert key)))
(insert key)))
;; Bind digits 0–9 to this behavior in math mode
(for-each (lambda (digit)
(bind-key (string-append " " digit)
(lambda () (auto-subscript-digit digit))))
'(“0” “1” “2” “3” “4” “5” “6” “7” “8” “9”))
Any help is appreciated comrades. I am new to modifying the program, though I’ve used it for a while. This is the only code in my my-init-texmacs.scm file, do I need something else?