Xah Talk Show 2021-05-17 Emacs Lisp Live Coding. Convert MM:SS to Seconds and Reverse
links mentioned:
- Emacs Lisp Basics
- Elisp: Using thing-at-point
- Elisp: Syntax Table
- Unicode for Programers
- Unicode: Character Set, Encoding, UTF-8, Codepoint
- unicode character categorization http://www.unicode.org/notes/tn36/
- Unicode: Cultural Religious Symbols π
- Unicode: Chinese δΈζ
- JS: RegExp Unicode Property
- Emacs: Xah Math Input Mode
(defun convertSecondsToMinSecs () "Convert seconds to mm:ss format, or vice versa, on current word. If the current word contains a colon, then do the reverse direction conversion. Version 2021-05-17" (interactive) (let (boundaryX p1 p2 wordX totalSecondsX minuteX secsX listX ) (save-excursion (search-backward " " ) (forward-char 1) (setq p1 (point)) (search-forward " " ) ;; (re-search-forward "[ \n]" ) (backward-char 1) (setq p2 (point))) (setq wordX (buffer-substring-no-properties p1 p2)) (if (string-match ":" wordX ) (progn (setq listX (split-string wordX ":" )) (setq minuteX (string-to-number (nth 0 listX))) (setq secsX (string-to-number (nth 1 listX))) (delete-region p1 p2) (insert (format "%s" (+ (* minuteX 60) secsX)))) (progn (setq totalSecondsX (string-to-number wordX)) (setq minuteX (/ totalSecondsX 60)) (setq secsX (% totalSecondsX 60)) (delete-region p1 p2) (insert (format "%s:%s" minuteX secsX ))))))xah_talk_show_2021-05-17.txt