Is there a better way? s-replace
Hay, everyone I have the following code that needs refactoring, I know there's a better way and I believe someone here is generous enough to show me. Thanks
(defun speak-content (start end)
"Speak selected region."
(interactive "r")
(save-excursion
(let* ((start (or start (region-beginning)))
(end (or end (region-end)))
(region (s-replace-regexp "/" ""
(s-replace-regexp "\\]" ""
(s-replace-regexp "\\[" ""
(s-replace-regexp "#" ""
(s-replace-regexp "~" "" (buffer-substring start end)))))))
(line (s-replace-regexp "/" ""
(s-replace-regexp "\\]" ""
(s-replace-regexp "\\[" ""
(s-replace-regexp "#" ""
(s-replace-regexp "~" "" (thing-at-point 'line)))))))
)
(if (region-active-p)
(play-audio (fetch-audio region))
(play-audio (fetch-audio line))))))
https://redd.it/i4uk4y
@r_emacs
Hay, everyone I have the following code that needs refactoring, I know there's a better way and I believe someone here is generous enough to show me. Thanks
(defun speak-content (start end)
"Speak selected region."
(interactive "r")
(save-excursion
(let* ((start (or start (region-beginning)))
(end (or end (region-end)))
(region (s-replace-regexp "/" ""
(s-replace-regexp "\\]" ""
(s-replace-regexp "\\[" ""
(s-replace-regexp "#" ""
(s-replace-regexp "~" "" (buffer-substring start end)))))))
(line (s-replace-regexp "/" ""
(s-replace-regexp "\\]" ""
(s-replace-regexp "\\[" ""
(s-replace-regexp "#" ""
(s-replace-regexp "~" "" (thing-at-point 'line)))))))
)
(if (region-active-p)
(play-audio (fetch-audio region))
(play-audio (fetch-audio line))))))
https://redd.it/i4uk4y
@r_emacs